Euler's Totient Function Calculator φ(n)

Find Euler's totient φ(n), the count of numbers from 1 to n that share no factor with n, with the prime factor formula worked out step by step.

From 1 up to 1,000,000,000,000 (10¹²).

Results

φ(200)
80
Prime factorization
200 = 2³ × 5²
Working
φ(200) = 200 × (1 − 1/2) × (1 − 1/5) = 80 Or, prime power by prime power: φ(2³) = 8 − 4 = 4; φ(5²) = 25 − 5 = 20; multiply: 4 × 20 = 80
Share of 1…n coprime to n
40.00 %
The 80 numbers coprime to 200
1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 47, 49, 51, 53, 57, 59, 61, 63, 67, 69, 71, 73, 77, 79, 81, 83, 87, 89, 91, 93, 97, 99, 101, 103, 107, 109, 111, 113, 117, 119, 121, 123, 127, 129, 131, 133, 137, 139, 141, 143, 147, 149, … (20 more)

How it’s calculated

Euler's totient function φ(n) counts the whole numbers from 1 to n that are relatively prime to n (share no factor with it other than 1). Counting them one by one is slow, but φ has a formula in terms of the prime factors of n: each distinct prime p dividing n removes the fraction 1/p of the numbers.

n = p₁^a₁ × p₂^a₂ × … × pₖ^aₖ φ(n) = n × (1 − 1/p₁) × (1 − 1/p₂) × … × (1 − 1/pₖ) φ(pᵃ) = pᵃ − pᵃ⁻¹; φ(p) = p − 1 for a prime p

φ is multiplicative: φ(m × n) = φ(m) × φ(n) when m and n are coprime. It appears in Euler's theorem, a^φ(n) ≡ 1 (mod n) whenever gcd(a, n) = 1, and in RSA encryption, where the private key is the inverse of the public exponent modulo φ(n).

Example: 200 = 2³ × 5². φ(200) = 200 × (1 − 1/2) × (1 − 1/5) = 200 × 1/2 × 4/5 = 80. Prime power by prime power: φ(2³) = 8 − 4 = 4 and φ(5²) = 25 − 5 = 20, and 4 × 20 = 80.

Frequently asked questions

What is φ of a prime number?

For a prime p, every number from 1 to p − 1 is coprime to p, so φ(p) = p − 1. For example φ(7) = 6.

Why is φ(1) = 1?

The only number from 1 to 1 is 1 itself, and gcd(1, 1) = 1, so it counts. This convention keeps the formula φ(m × n) = φ(m) × φ(n) working.

How is φ(n) used in RSA?

With n = p × q for two primes, φ(n) = (p − 1)(q − 1). The private exponent d is the inverse of the public exponent e modulo φ(n). For p = 61 and q = 53, n = 3233 and φ = 3120.

Is φ(n) always even?

Yes, for every n of 3 or more. The numbers coprime to n pair up as k and n − k, which are never equal when n > 2.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator