(* There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 235, 245, and 345 In combinatorics, we use the notation, ^(5)C_(3) = 10. In general, ^(n)C_(r) = n! r!(n?r)! ,where r ? n, n! = n×(n?1)×...×3×2×1, and 0! = 1. It is not until n = 23, that a value exceeds one-million: ^(23)C_(10) = 1144066. How many, not necessarily distinct, values of ^(n)C_(r), for 1 ? n ? 100, are greater than one-million? *) open Big_int;; let bmill = big_int_of_int 1000000;; (* n!/(r!*(n-r!)) *) let comb r n = let rec fact i n = if(i>n) then (big_int_of_int 1) else mult_int_big_int i (fact (i+1) n) in div_big_int (fact (r+1) n) (fact 2 (n-r)) ;; let rec search r n = if(n>100) then 0 else if(r>n) then (search 0 (n+1)) else ( if (gt_big_int (comb r n) bmill) then 1 else 0 ) +(search (r+1) n) ;; Printf.printf "%d\n" (search 0 0);;