This one should be faster since we only compute 2 products of less numbers.
module NCR where --Combinations nCr comb:: Integer -> Integer -> Integer comb n r = product [n-r+1..n] `div` product [2..r]
- module NCR where
- --Combinations nCr
- comb:: Integer -> Integer -> Integer
comb n r = factorial n `div` (factorial r * factorial (n-r))wherefactorial n = product [1 .. n]- comb n r = product [n-r+1..n] `div` product [2..r]