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...
Please try to write some code first and then we can help you with that. Alternatively, write some pseudocode so we can see what conceptual issues you are having.
~j
are those bits???
is n and r integers???
how about stating your problem clearly
and with your code...
>..<
I Would elaborate the question:
since n & r values could be very large, and in order to find nCr, n! & r! would have to be calculated, so it is not possible to define a datatype that can hold these factorial values...
instead what i planned to do was that in order to find the factorial, i could create an array, that could hold the values of the multiplication.
for ex: if i have to find 10!,
i wud create an array and store the values as
3 6 2 8 8 0 0 .
so instead of storing the whole value as some datatype, i can
store each value at continuous locations in the array.
but the problem here is, this method will have to be applied both in numerator & denominator, so what i am unable to figure out is how to solve it efficiently.
i hope the problem's much clearer now... :)