24 lines
463 B
Plaintext
24 lines
463 B
Plaintext
// 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
|
|
// What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
|
|
//
|
|
// Correct Answer: 232_792_560
|
|
|
|
fun gcd(x, y) {
|
|
loop y {
|
|
tmp <- x;
|
|
x = y;
|
|
y = tmp % y;
|
|
}
|
|
|
|
return x;
|
|
}
|
|
|
|
result <- 1;
|
|
|
|
i <- 1;
|
|
loop i <= 20; i = i + 1 {
|
|
result = result * (i / gcd(i, result));
|
|
}
|
|
|
|
print result;
|