0
$\begingroup$

With the $C_n^k$ formula, I managed to optimize it for finding very big numbers such as $C_{7130}^{7125}$ rather quickly. I could have used GMP or Ruby because unsigned long don't hold a lot of values, but here is my question:

Are there applications where people need to compute such numbers ? Because the plain factorial methods can be quite long compared to my method...

  • 0
    ...or this one, which is simil$a$r: http://www.num$b$ertheory.org/php/binomial.html2011-04-22

1 Answers 1

2

Yes, there are all sorts of reasons why you might want to know a large binomial coefficient. Is this what you have?

some_int_type nCr = 1 ; if (r > n/2) r = n - r ; for (int i = 1 ; i <= r ; i++, n--)   nCr *= n, nCr /= i ; 
  • 0
    WELL THEY SHOULD BE!2011-04-26