Modular Exponentiation by 51b

-module m.
-export[m/0].
m()->io:write(g(2,100)).
p(0)->1;p(M)->10*p(M-1).
f(_,0)->1;f(N,M)->N*f(N,M-1)rem p(1000).
g(N,0)->N;g(N,M)->g(f(N,10),M-1).

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page