namanvats / cpalgorithms

Algorithms and Techniques for competitive programming
MIT License
17 stars 30 forks source link

Added functions for calculation of ncr%p using lucas theorem and fermat theorem, as asked in many CP problems. #42

Closed kartikeytewari closed 1 year ago

kartikeytewari commented 3 years ago

The implementation of Fermat theorem is done using persistent factorial approach making the Time Complexity very optimized. Also Lucas theorem is implemented using persistent DP making the Time Complexity appreciably good.

Both codes also have the theoretical Time and Space Complexity written as comments.