Skip to content

Instantly share code, notes, and snippets.

@dmalikov
Created January 3, 2012 22:47
Show Gist options
  • Save dmalikov/1557385 to your computer and use it in GitHub Desktop.
Save dmalikov/1557385 to your computer and use it in GitHub Desktop.
Project Euler 203 (0.02s)
import Data.Numbers.Primes (primeFactors)
import Data.List (group, nub, sort)
import Control.Arrow ((&&&))
import PECore
squarefree :: Integer -> Bool
squarefree = all ((< 2) . snd) . map ((&&&) head length) . group . primeFactors
numFromPascalTriangles :: Integer -> [Integer]
numFromPascalTriangles n = nub . sort . concat . map (\x -> map (combinations x) $ [0..x]) $ [0..n-1]
main = print . sum . filter squarefree . numFromPascalTriangles $ 51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment