The most efficient way to calculate nCr mod M in cases when M isn't prime

963 Views Asked by At

I have always faced lots of questions on online coding platforms dealing with nCr mod M where M is usually a prime. In the cases where it is not, we usually prefer to use the Chinese remainder theorem

Could we do this more easily than the Chinese Remainder Theorem, i.e. by writing less code if we simply have to calculate N mod M where M is not prime?

0

There are 0 best solutions below