Best known algos for calculating nCr % M

Amazing Detail. Cheers. Just a great feeling seeing someone spend so much time and energy typing this out for others. :slight_smile:

P.S. @anudeep2011:Lucasā€™ Theorem holds true even for prime powers(like 27=3^3) (Called generalized Lucasā€™ theorem)

2 Likes

Would be great if there was separate thread about this in latex format. Great answer!!

hey can anyone tell me when to use lucas theorem and when to use fermat theorem.

1 Like

Lucas n>>p, else fermat.

2 Likes

This post was flagged by the community and is temporarily hidden.