Robert Atkinson robertatkinson.co.uk
Modulo
Purpose
To help investigate Fermat's Little Theorem - in particular to illustrate the arrangement of 1 and -1 results from the development of Fermat's theorem (Robert's Little Theorem, as explained in the Writing section). The program will also illustrate any modulo calculation by setting the power (p) to 1.
Method
The program calculates the least residue (r) of any number (n) raised to a given power (p) in a given modulo (m), and its congruent equivalent (c) in terms of positive numbers clockwise from 0 (1, 2, 3, ...) or negative numbers anti-clockwise (-1, -2, -3, ...).

The program stages are:

First - set up a modulus circle with a certain number of elements (m).

Second - raise each element in the circle (n) by a given power (p) to give a number (x).

Third - calculate the quotient (q) and remainder (r) when (x) is divided by (m).

Fourth - translate (r) into positive/negative numbers (c) in relation to the 0 point of the modulus.





n x = np x/m (q) x/m (r) c (mod m)