Ad

Just used the builtin function product to make things a bit nicer.

Code
Diff
  • module NCR where
    
    --Combinations nCr
    comb:: Integer -> Integer -> Integer
    comb n r = factorial n `div` (factorial r * factorial (n-r))
      where
      factorial n = product [1 .. n]
    • module NCR where
    • --Combinations nCr
    • comb:: Integer -> Integer -> Integer
    • comb n r = factorial n `div` (factorial r * factorial (n-r))
    • where
    • factorial n = foldr (*) 1 [2..n]
    • factorial n = product [1 .. n]