Project Euler Problem 053
import Data.List nck :: Integral a => a -> a -> a nck n k = product [n-k+1..n] `quot` product [1..k] ans1 :: Int ans1 = length $ filter (>1000000) [nck n k | n<-[1..100],k<-[1..100::Integer]] count :: Integral b => b -> b -> b count maxn limit= imp maxn 0 where imp n r = case over n r of Nothing -> 0 Just r' -> (n - 2*r'+1) + imp (n-1) r' over n r = find ((>limit).(nck n)) [r..(maxn`quot`2)] ans2 :: Integer ans2 = count 100 1000000 --4075 main :: IO () main = print ans1