hi frndz....
i was wondering that given
1<n<1000000 &
1<r<1000000
how do i efficiently find nCr (combination) for any given values of n & r.
please help with an efficient algorithm...
hi frndz....
i was wondering that given
1<n<1000000 &
1<r<1000000
how do i efficiently find nCr (combination) for any given values of n & r.
please help with an efficient algorithm...
Forgive my ignorance of mathematics but it would seem to me this does not any algorithm.
[aside:] For some silly reason cboard's vBulletin believes everything in braces is code...unless you are new and want to paste a few hundred linesCode:{r,n}
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
As nCr would be factorial(n)/(factorial(r)*factorial(n-r)) I guess it boils down to finding the factorial efficiently.
If an approximate solution would be okay, then go for http://en.wikipedia.org/wiki/Stirling%27s_approximation
Not everything that can be counted counts, and not everything that counts can be counted
- Albert Einstein.
No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
- Herbert Mayer