Talk:Modular exponentiation
Appearance
Could discuss top down vs. bottom up exponentiation.
Could add optimizations (for "top down") that are faster but use more memory. Examples: bit windowing (or sliding windows).
modpow is not complete. for all x, (x^1 mod 1) is 0, not 1.
because e is zero, the loop is ignored and a result of 1 is returned.
one general fix for this is:
return result % m;
another would be a fairly thorough conditional statement.