I am trying to make a function that tests the command time
in python. The function should take m,n
as a parameters and calculates MODEXP(a,e,p)
You code runs fine on my box without hanging. As others have pointed out, it is O(2**n), hence the run time grows exponentially. Here my timing:
m = n = 2; time needed: 1.90734863281e-05
m = n = 3; time needed: 1.50203704834e-05
m = n = 4; time needed: 2.21729278564e-05
m = n = 5; time needed: 4.38690185547e-05
m = n = 6; time needed: 9.41753387451e-05
m = n = 7; time needed: 0.000232934951782
m = n = 8; time needed: 0.000643014907837
m = n = 9; time needed: 0.00198698043823
m = n = 10; time needed: 0.00656795501709
m = n = 11; time needed: 0.0229339599609
m = n = 12; time needed: 0.082200050354
m = n = 13; time needed: 0.299206972122
m = n = 14; time needed: 1.09857010841
m = n = 15; time needed: 4.06366610527
m = n = 16; time needed: 15.0994331837
m = n = 17; time needed: 56.4191129208
For m = n = 100, it would take roughly 1.3 * 10^49 seconds.