Skip to content

Euler’s Theorem Calculator

Updated:

Apply Euler’s Theorem online: enter a base a and a modulus n (coprime), and the calculator computes Euler’s totient φ(n) and a^φ(n) mod n, which always equals 1 when the theorem’s conditions hold.

Compute Modular Powers Using Euler’s Theorem

Input Fields
Enter the integer base "a"
Enter the modulus "n" (should be > 1)
If enabled, the result will update automatically when you change any value.

Euler’s Theorem Formula

Formula
\[ \text{If } \gcd(a, n) = 1, \quad \text{then } a^{\phi(n)} \equiv 1 \pmod{n} \]

Where:

  • \(a\) — the base, an integer coprime with \(n\)
  • \(n\) — the modulus, a positive integer
  • \(\phi(n)\) — Euler’s totient function: the count of integers from \(1\) to \(n\) that are coprime with \(n\)
  • \(\equiv 1 \pmod{n}\) — the left and right sides leave the same remainder \(1\) when divided by \(n\)

The theorem states that whenever \(a\) and \(n\) share no common factor other than 1, raising \(a\) to the power \(\phi(n)\) always yields \(1\) modulo \(n\). This makes it possible to reduce very large exponents in modular arithmetic to much smaller ones.

Euler’s Theorem – Calculation Example

Example: verify Euler’s Theorem for \(a = 3\) and \(n = 7\) (the calculator’s default values).

Step 1: check that \(a\) and \(n\) are coprime:

\[ \gcd(3, 7) = 1 \quad \checkmark \]

Step 2: compute the totient of \(n\). The numbers coprime with \(7\) among \(1, 2, \dots, 6\) are all six of them, so:

\[ \phi(7) = 6 \]

Step 3: raise the base to that power and reduce:

\[ 3^{6} = 729 \equiv 1 \pmod{7} \]

Result: \(a^{\phi(n)} \bmod n = 1\), exactly as Euler’s Theorem predicts.

How to Use the Calculator

  1. Enter the integer base \(a\) in the Base number (a) field.
  2. Enter the modulus \(n\) in the Modulus (n) field. Use a value greater than 1 for a meaningful result.
  3. Read the two outputs: Euler’s Totient φ(n) shows how many numbers below \(n\) are coprime with it, and a^φ(n) mod n shows the modular power.
  4. If you see the message “a and n must be coprime”, choose a different pair — Euler’s Theorem does not apply when \(\gcd(a, n) > 1\).

What Is Euler’s Theorem?

Euler’s Theorem, stated by Leonhard Euler in 1763, is one of the central results of number theory. It says that if an integer \(a\) shares no common divisor with \(n\) other than 1, then \(a^{\phi(n)}\) leaves a remainder of \(1\) when divided by \(n\). The key quantity here is Euler’s totient function \(\phi(n)\), which counts how many integers between \(1\) and \(n\) are coprime with \(n\). For a prime \(p\), every number from \(1\) to \(p-1\) qualifies, so \(\phi(p) = p - 1\).

The theorem generalizes Fermat’s Little Theorem: setting \(n = p\) prime gives \(a^{p-1} \equiv 1 \pmod{p}\), which is exactly Fermat’s statement. Conversely, Euler’s version works for any modulus, prime or composite, as long as the base and modulus are coprime.

In practice, the theorem is a powerful computational shortcut. To compute something like \(a^{k} \bmod n\) with a huge exponent \(k\), you can replace \(k\) with \(k \bmod \phi(n)\), because the exponents repeat with period \(\phi(n)\). This reduction is the reason modular exponentiation with very large numbers stays fast — a property that modern cryptography depends on.

Indeed, Euler’s Theorem is a cornerstone of RSA encryption. The private decryption exponent is chosen so that \(e \cdot d \equiv 1 \pmod{\phi(n)}\), which guarantees that raising a ciphertext to the power \(d\) recovers the original message. Without Euler’s Theorem, the correctness of RSA could not be proven.

Assumptions, Limitations and Tips

  • Coprimality is required. The theorem holds only when \(\gcd(a, n) = 1\). The calculator checks this and shows an error message otherwise. For example, \(a = 4\), \(n = 6\) fails because both are divisible by 2.
  • Modulus must be at least 2. With \(n = 1\) every integer is congruent to \(0\), so the statement degenerates. Enter \(n > 1\).
  • The result is always 1. When the conditions are met, \(a^{\phi(n)} \bmod n = 1\) by definition — the calculator is a verification and learning tool. To actually simplify a custom exponent, reduce it modulo \(\phi(n)\) first and then use fast modular exponentiation.
  • Computing \(\phi(n)\). This calculator counts coprimes directly, which is fine for small moduli. For large \(n\) with known factorization, use \(\phi(n) = n \prod_{p \mid n} \left(1 - \tfrac{1}{p}\right)\) instead.
  • Related tools. To find the number that “undoes” multiplication by \(a\) modulo \(n\), use the Multiplicative Inverse Modulo calculator; to solve systems of congruences, see the Chinese Remainder Theorem calculator.

Frequently Asked Questions

How do I calculate Euler's Theorem by hand?

First verify that \(\gcd(a, n) = 1\). Then count how many integers from 1 to \(n\) share no factor with \(n\) — that count is \(\phi(n)\). Finally compute \(a^{\phi(n)}\) and divide by \(n\); the remainder will be 1. For example, with \(a = 5\), \(n = 12\): the coprimes are 1, 5, 7, 11, so \(\phi(12) = 4\) and \(5^4 = 625 = 52 \times 12 + 1\).

Why does my calculator show an error for some inputs?

The error appears when the base and modulus are not coprime, i.e. \(\gcd(a, n) > 1\). For instance, \(a = 6\) and \(n = 9\) both divide by 3, so Euler's Theorem simply does not apply to that pair. Either change the base or pick a different modulus. Also make sure \(n > 1\), because with \(n = 1\) the statement degenerates.

What is a quick way to compute Euler's totient φ(n) for large numbers?

Counting coprimes one by one works only for small \(n\). If you know the prime factorization, use the product formula \(\phi(n) = n \prod_{p \mid n} \left(1 - \tfrac{1}{p}\right)\). For example, \(n = 36 = 2^2 \cdot 3^2\), so \(\phi(36) = 36 \cdot \tfrac{1}{2} \cdot \tfrac{2}{3} = 12\). If \(n\) is prime, \(\phi(n) = n - 1\) with no factoring needed.

How is Euler's Theorem different from Fermat's Little Theorem?

Fermat's Little Theorem is the special case of Euler's Theorem where the modulus is prime: \(a^{p-1} \equiv 1 \pmod{p}\). Euler generalized it in 1763 to any modulus \(n\), prime or composite, replacing the exponent \(p-1\) with \(\phi(n)\). So Euler's version covers cases like \(n = 15\) or \(n = 100\) where Fermat's original statement says nothing.

Can the result ever be something other than 1?

No — whenever \(\gcd(a, n) = 1\) and \(n > 1\), the result is guaranteed to be exactly 1. That is the whole point of the theorem. If you get a different value, the inputs violate the conditions (most commonly a hidden common factor). If you need \(a^k \bmod n\) for a custom exponent \(k\), reduce \(k\) modulo \(\phi(n)\) first and use a modular exponentiation tool instead.

How is Euler's Theorem used in real life?

Its most famous application is RSA encryption. An RSA private key \(d\) is chosen so that \(e \cdot d \equiv 1 \pmod{\phi(n)}\), and Euler's Theorem guarantees that decrypting a ciphertext recovers the original message. The same exponent-reduction trick \(a^k \equiv a^{k \bmod \phi(n)} \pmod{n}\) also keeps modular arithmetic with huge numbers fast in cryptography and computer science.

What is the smallest exponent that gives 1, and how does it relate to φ(n)?

The smallest positive exponent \(k\) with \(a^k \equiv 1 \pmod{n}\) is called the multiplicative order of \(a\) modulo \(n\). Euler's Theorem guarantees this order exists and always divides \(\phi(n)\), but it is often smaller. For example, \(\phi(7) = 6\), yet the order of \(2\) modulo 7 is only 3, since \(2^3 = 8 \equiv 1 \pmod{7}\).

Leave a Reply

Your email address will not be published. Required fields are marked *