Question
There are exactly ten ways of selecting three from five, 12345:
In combinatorics, we use the notation, .
In general,
It is not until , that a value exceeds one-million: .
How many, not necessarily distinct, values of , for , are greater than one-million?
Haskell
choose :: Integer -> Integer -> Integer
choose _ 0 = 1
choose 0 _ = 0
choose n r = choose (n-1) (r-1) * n `div` r
main :: IO ()
main = print $ length $ filter (> 1000000) [n `choose` r | n <- [1..100], r <- [1..n]]
$ ghc -O2 -o combinatoric-selections combinatoric-selections.hs
$ time ./combinatoric-selections
real 0m0.013s
user 0m0.013s
sys 0m0.000s