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.
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.