Foundation 라이브러리 안에있는 sqrt함수를 사용하면 제곱근을 구할 수 있다. import Foundation func solution(_ n:Int64) -> Int64 { let root = Int64(sqrt(Double(n))) if n==root*root { return (root+1)*(root+1) } else { return -1 } }
Foundation 라이브러리 안에있는 sqrt함수를 사용하면 제곱근을 구할 수 있다.
import Foundation func solution(_ n:Int64) -> Int64 { let root = Int64(sqrt(Double(n))) if n==root*root { return (root+1)*(root+1) } else { return -1 } }