Created
May 12, 2013 06:51
-
-
Save asbubam/5562675 to your computer and use it in GitHub Desktop.
Euler scala Ex05
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
1 ~ 10 사이의 어떤 수로도 나누어 떨어지는 가장 작은 수는 2520입니다. | |
그러면 1 ~ 20 사이의 어떤 수로도 나누어 떨어지는 가장 작은 수는 얼마입니까? | |
*/ | |
object Ex05 extends App { | |
var allLcm = BigInt(1) | |
for(i <- (1 to 20)) { | |
allLcm = lcm(BigInt(i), allLcm) | |
} | |
println(allLcm.toString()) | |
def lcm(x: BigInt, y:BigInt): BigInt = { | |
x / x.gcd(y) * y | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment