module Euler5 // 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? imports Prelude Data.Stack where main :: () -> I32 main () = do i = new 1 while (not (all_20 @i)) (inc i) putW @i assert (@i == 232792560) 0 is_factor :: { Arith a, Eq a } => a -> a -> Bool is_factor x y => (x % y) == 0 all_20 :: W32 -> Bool all_20 x = do b = new True for 1 (\i -> (i <= 20) && @b) succ (\i -> b <- is_factor x i) @b