I want to calculate ab mod n for use in RSA decryption. My code (below) returns incorrect answers. What is wrong with it?
unsigned long i
For my code a^k mod n in php:
function pmod(a, k, n) { if (n==1) return 0; power = 1; for(i=1; i<=k; $i++) { power = (power*a) % n; } return power; }