Add project euler example 5
This commit is contained in:
parent
f8e5bd7423
commit
c2b9ee71b8
28
examples/euler5.nek
Normal file
28
examples/euler5.nek
Normal file
@ -0,0 +1,28 @@
|
||||
// 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;
|
||||
i <- 2;
|
||||
|
||||
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;
|
||||
Loading…
x
Reference in New Issue
Block a user