nek-lang/examples/euler5.nek
2022-02-09 17:12:47 +01:00

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