Computing an mod m

This web form computes an mod m using a perl script. The perl script simply implements the algorithm from class in which if n is even we replace a by a2 mod m and n by n/2, or, if n is odd, we replace a by a2 mod m and n by (n-1)/2, but in addition we have an extra factor of a to keep track of.

To compute an mod m, enter the values below (a, n and m must be positive integers of no more than 7 digits; any which are not will be replaced by the number 1):

Enter the desired values of a, n and m:
a=
n=
m=