C(n,k) is largest for k = n/2 for n even, and k = (n-1)/2 and (n+1)/2 for n odd which are always the same. You can see that from Pascal's triangle. These are just the binomial coefficients.
Code:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
...
The nth line (starting with line 0) is C(n,k) for k going across from 0 to n. It's largest in the middle, and the largest keeps getting larger for larger n. Each number is the sum of the 2 above it. That's from the recursion
C(n,k) = C(n-1,k-1) + C(n-1,k).
Do you have to represent all the digits of the number to the one's place? If so, then you can't even do C(17,6) = 12376 which requires 5 digits. You can do C(16,8) and all the 16's because the 5 digit ones all end in 0, so you can use the exponent.
> C(16,0:16)
[1] 1 16 120 560 1820 4368 8008 11440 12870 11440 8008 4368
[13] 1820 560 120 16 1
Usually we don't worry about representing all the digits for large numbers any more than we would worry about representing all the decimal digits for small numbers. If you just need it not to overflow, then you can do C(53,k) for all k, but not C(54,k) or C(55,k) or anything higher which would have one larger than C(55,27) since Pascal's triangle for C(56,28) will add C(55,27) to C(55,28), and so on.
Also, we can compute C(m,k) for a number higher than m! since we can do
m/k/(m-k) * (m-1)/(k-1)/m-k-1) * ...
or even sum logs instead of multiplying and then exponentiate, but there would be loss of precision in these steps if you care about that.
Last edited by BruceZ; 02-16-2013 at 08:36 PM.