nek-lang/examples/euler5.nek
2022-02-04 14:25:25 +01:00

27 lines
574 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
num <- 20;
should_continue <- 1;
loop should_continue {
should_continue = 0;
i <- 20;
loop i >= 2; i = i - 1 {
if num % i != 0 {
should_continue = 1;
// break
i = 0;
}
}
if should_continue == 1 {
num = num + 20;
}
}
print num;