[Swift] 백준2609
·
📝 코테/BOJ
import Foundation let line = readLine()!.components(separatedBy: " ").map { Int($0)! } var n = line[0] var m = line[1] func getGCD(n1: Int, n2: Int) -> Int { if n2 == 0 { return n1 } else { return getGCD(n1: n2, n2: n1 % n2) } } func getLCM(num1: Int, num2: Int) -> Int { return num1 * num2 / getGCD(n1: num1, n2: num2) } print(getGCD(n1: n, n2: m)) print(getLCM(num1: n, num2: m))