From c2b9ee71b86f94752b351d1cdb50cb843215d75c Mon Sep 17 00:00:00 2001 From: Daniel M Date: Thu, 3 Feb 2022 16:16:38 +0100 Subject: [PATCH] Add project euler example 5 --- examples/euler5.nek | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/euler5.nek diff --git a/examples/euler5.nek b/examples/euler5.nek new file mode 100644 index 0000000..9bae674 --- /dev/null +++ b/examples/euler5.nek @@ -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;