Problem 203

203 Squarefree Binomial Coefficients

Problem 203 – Project Euler

とりあえず、適当につくったら、そのまま解けてしまった。

import Data.List (group, nub)
import Number (factors)
pascal :: [[Integer]]
pascal = iterate next [1]
where next xs = zipWith (+) (:xs) (xs++[])
p203 :: Int -> Integer
p203 n = sum.filter sqFree.nub.concat.take n $ pascal
where sqFree = all (null.tail).group.factors
main = print.p203 $ 51
More Reading
Newer// Problem 202
Older// Problem 205