This post exploits the recurrence :

C(n,k) = C(n-1, k) + C(n-1, k-1)

If the limits to n are known, then the above recurrence can be used for dynamic programming.

Implementation:

C(n,k) = C(n-1, k) + C(n-1, k-1)

If the limits to n are known, then the above recurrence can be used for dynamic programming.

Implementation:

may be you should un-comment the commented part.For C_MAX with value 250, It exceeds the bounds of an integer.

ReplyDeleteDone! Thanks!

ReplyDeleteyou could also have used http://en.wikipedia.org/wiki/Lucas'_theorem for this problem

ReplyDelete