|
|
@@ -0,0 +1,18 @@
|
|
|
+{-
|
|
|
+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 with no remainder by all of the numbers from 1 to 20?
|
|
|
+-}
|
|
|
+
|
|
|
+evenly_div :: Int -> Int -> Bool
|
|
|
+evenly_div x 0 = True
|
|
|
+evenly_div x 1 = True
|
|
|
+evenly_div x y = if (mod x y) == 0 then evenly_div x (y - 1) else False
|
|
|
+
|
|
|
+solution' :: Int -> Int
|
|
|
+solution' x = if (evenly_div x 20) then x else solution' (x + 1)
|
|
|
+
|
|
|
+solution :: Int
|
|
|
+solution = solution' 1
|
|
|
+
|
|
|
+main :: IO ()
|
|
|
+main = putStrLn ("Solution: " ++ show solution)
|