modular inverse fermat little theorem Algorithm

If a is not divisible by p, Fermat's small theorem is equivalent to the statement that ap − 1 − 1 is an integer multiple of p. Fermat’s small theorem is the basis for the Fermat primality test and is one of the fundamental outcomes of elementary number theory. Pierre de Fermat first stated the theorem in a letter dated October 18, 1640, to his friend and confidant Frénicle de en tous nombres premiers; de quoiHis formulation is equivalent to the following: If p is a prime and a is any integer not divisible by p, then a p − 1 − 1 is divisible by p.

modular inverse fermat little theorem source code, pseudocode and analysis