Hello ... I have a simple idea (eventhough I'm sure it still needs to be improved) ...
Let's put one example to make things clear a little bit ... consider:
-> 100 C 30 = ????
so you would have to calculate 100! / (30! x 70!)
You can definitely cross out 70! (I pick the larger number) since we know we can write it as:
100 x 99 x 98 x .... 71 x 70!
---------------------------------
30! x 70!
You'll end up with:
100 x 99 x 98 x ... 71
-------------------------
30 x 29 x 28 x ... x 1
For this, you can have one integer array that contains: {100, 99, .. 71 } and another array contains {30, 29, 28, ... 1} ... Previously we pick larger number (70 instead of 30) to handle less elements in both arrays.
Now the goal is to iterate in such a way that your second array will contain all ones. { 1, 1, 1 ... } ...
I think we stop here so you'll still have some fun writing your solution
Oh yes, BTW, you can also try solve similar problems 10338 - Mischievous Children.
-turuthok-