Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
9 lines (8 sloc) 291 Bytes
findMultiple :: Int -> Int -> Int
findMultiple currentProd next =
if mod currentProd next == 0
then currentProd
else currentProd * firstPrimeDivisor next
where firstPrimeDivisor n = head [ d | d <- [2..n], mod n d == 0 ]
euler5 :: Int -> Int
euler5 n = foldl findMultiple 1 [1..n]