MathorynMathematical Formula Database

Number Theory

Euler's Theorem

Euler's theorem generalises Fermat's little theorem to any modulus using the totient function. It is used to reduce huge exponents in modular arithmetic, to find last digits of powers and it is the mathematical basis of RSA encryption.

aφ(n)≡1(modn)if gcd⁡(a,n)=1a^{\varphi(n)}\equiv1\pmod n\quad\text{if}\ \gcd(a,n)=1
LaTeXa^{\varphi(n)}\equiv1\pmod n\quad\text{if}\ \gcd(a,n)=1

Variables

aa
integer coprime to n
nn
positive integer modulus
φ(n)\varphi(n)
Euler's totient of n

Example

Find the last digit of 320263^{2026}.

  1. φ(10)=4\varphi(10)=4, so 34≡1(mod10)3^4\equiv1\pmod{10}.
  2. 2026=4⋅506+22026=4\cdot506+2, so 32026≡32=93^{2026}\equiv3^2=9.

Answer: The last digit is 99.

Related formulas