I always see problems that need to print the result of C(n,m) mod a prime number where C(n,m) = n!/(m!*(n-m)!) the factorial formula of binomial coefficients. I've searched for it and I found that I need to find the multiplicative inverse using extended Euclidean algorithm and I've learnt it. I hope if somebody could tell me the fastest way to find C(n,m) mod P (P is a prime) using extended Euclidean algorithm and I would be thankful if there was a code. Thanks a lot.