Skip to content
Browse files

euler 47

  • Loading branch information...
1 parent ee137fe commit 8857e582ba61811fc14699222efcad25c61396d1 @andrusha committed
Showing with 13 additions and 0 deletions.
  1. +13 −0 euler/47.hs
View
13 euler/47.hs
@@ -0,0 +1,13 @@
+-- Find the first four consecutive integers to have four
+-- distinct primes factors. What is the first of these numbers?
+
+import Data.List (nub)
+import Numerix (primeFactors)
+
+fours = map (\x -> [x, x+1, x+2, x+3]) [0..]
+
+fourPF = (== 4) . length . nub . primeFactors
+
+answer = head . dropWhile (not . all fourPF) $ fours
+
+main = print $ head answer

0 comments on commit 8857e58

Please sign in to comment.
Something went wrong with that request. Please try again.