How to solve this calculation ?

C(N,K)%M , where M is a prime number , N and K is very big number (N<=10^6), How is solution ?

@mehemmedv : Refer to this thread :

http://discuss.codechef.com/questions/4698/use-of-modulo-1000007-in-competitions

You will need to precompute factorials and use the idea of multiplicative inverse .

@vineetpaliwal Thanks.

http://discuss.codechef.com/questions/3869/best-known-algos-for-calculating-ncr-m

You’re welcome.