euler totient function calculator

Tip: You can press Enter after typing your number.

What This Euler Totient Calculator Does

This calculator computes Euler’s totient function, written as φ(n), for any positive integer you provide. The totient function tells you how many integers from 1 to n are relatively prime to n (that is, they share no common factors with n other than 1).

In addition to the final value, the tool also shows:

  • The prime factorization of your input
  • The product formula used to compute φ(n)
  • Step-by-step simplification
  • A list of coprime numbers for small values of n

Euler’s Totient Function: Quick Definition

For a positive integer n, Euler’s totient function is:

φ(n) = number of integers k with 1 ≤ k ≤ n and gcd(k, n) = 1

Example: for n = 9, the numbers coprime to 9 are 1, 2, 4, 5, 7, and 8, so φ(9) = 6.

How the Formula Works

If the distinct prime factors of n are p1, p2, ..., pr, then:

φ(n) = n ∏(1 - 1/p)   (product over distinct prime divisors p of n)

This is equivalent to removing, proportionally, all numbers divisible by each prime factor of n. It is fast and exact when we know the prime factorization.

Special Cases You Should Know

  • φ(1) = 1
  • If p is prime, φ(p) = p - 1
  • If n = pk, then φ(n) = pk - pk-1
  • If gcd(a, b) = 1, then φ(ab) = φ(a)φ(b) (multiplicative property)

Worked Examples

Example 1: n = 36

Prime factorization: 36 = 22 × 32

φ(36) = 36(1 - 1/2)(1 - 1/3) = 36 × 1/2 × 2/3 = 12

Example 2: n = 49

Prime factorization: 49 = 72

φ(49) = 49(1 - 1/7) = 49 × 6/7 = 42

Example 3: n = 101 (prime)

φ(101) = 100

Why Euler’s Totient Function Matters

Euler’s totient function appears in many areas of number theory and cryptography:

  • RSA encryption: security and key generation depend on totients of large semiprimes.
  • Modular arithmetic: Euler’s theorem uses φ(n) to simplify large powers modulo n.
  • Reduced fractions: counts fractions in simplest form with denominator n.
  • Group theory: gives the size of the multiplicative group modulo n.

Using This Calculator Effectively

  1. Enter a positive integer n.
  2. Click Calculate φ(n).
  3. Read the result, factorization, and the formula steps.
  4. For small n, inspect the explicit coprime list to build intuition.
Note: Factorization by trial division is reliable but can be slow for very large numbers with large prime factors. For educational use and moderate-size inputs, it performs well.

FAQ

Is φ(n) always smaller than n?

For n > 1, yes. The only case where φ(n) equals n is not possible for n > 1. For n = 1, φ(1) = 1.

Can two different numbers have the same totient value?

Yes. For example, φ(15) = 8 and φ(16) = 8.

Is this useful for cryptography classes?

Absolutely. This tool helps verify hand calculations and understand why RSA uses products of primes.

🔗 Related Calculators