TL;DR
Haskellの勉強を兼ねてProject Eulerを解いていきます。
始めたばかりでわからないことが多いのでコメント頂けると嬉しいです。
問題文
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?2520 は 1 から 10 の数字の全ての整数で割り切れる数字であり, そのような数字の中では最小の値である.
では, 1 から 20 までの整数全てで割り切れる数字の中で最小の正の数はいくらになるか.
コード
isDivisible::Int -> Bool
isDivisible n = all (==True) [n `mod` x == 0 | x <- [11..20]]
main::IO()
main = do
print $ (2+) $ maximum $ takeWhile (\x -> not $ isDivisible(x)) [x | x <- [2520,2522..]]
めちゃくちゃ遅いからどうにかしたい…