백준 2609 최대공약수와 최소공배수
문제 : https://www.acmicpc.net/problem/2609
유클리드 호제법으로 풀었다.
Swift :
let input = readLine()!.split(separator: " ").map{Int($0)!}
let gcd = GCD(input[0], input[1])
print(gcd)
print(input.reduce(1, *) / gcd)
func GCD(_ x: Int,_ y: Int) -> Int{
return y != 0 ? GCD(y, x%y) : x
}