Euler’s Totient Function Calculator with Steps

Calculate φ(n), see the prime factorization and Euler product formula, and follow each exact integer step. Inputs stay in your browser.

Enter a positive integer

Digits may include commas, spaces, or underscores as grouping separators. Decimals, zero, and negative integers are not accepted.

Result and working

Your result will appear here.

Try 36 to see φ(36) = 12 and the steps using the distinct primes 2 and 3.

Advertisement

What is Euler’s totient function?

Euler’s totient function, written φ(n) and sometimes called Euler’s phi function, counts the positive integers from 1 through n that are relatively prime to n. Two numbers are relatively prime, or coprime, when their greatest common divisor is 1.

Euler product formula: φ(n) = n ∏p | n (1 − 1/p)

The product uses each distinct prime divisor p of n exactly once. This calculator evaluates the equivalent integer update result = result − result / p, so no floating-point rounding is introduced.

For example, 36 = 22 × 32. Its distinct prime divisors are 2 and 3, so φ(36) = 36(1 − 1/2)(1 − 1/3) = 12.

Worked totient examples

Prime number: φ(13)

Since 13 is prime, its only prime divisor is 13:

φ(13) = 13 − 13/13 = 12

Every integer from 1 through 12 is coprime to 13.

Prime power: φ(32)

Because 32 = 25, use the distinct prime 2 once:

φ(32) = 32 − 32/2 = 16

More generally, φ(pk) = pk − pk−1.

Two distinct primes: φ(15)

Since 15 = 3 × 5:

φ(15) = 15(1 − 1/3)(1 − 1/5) = 8

The coprimes are 1, 2, 4, 7, 8, 11, 13, and 14.

Several prime factors: φ(360)

Since 360 = 23 × 32 × 5:

φ(360) = 360 × 1/2 × 2/3 × 4/5 = 96

Only the distinct primes 2, 3, and 5 affect the product.

Common Euler totient values

nPrime factorizationφ(n)Reason
1Empty product1Standard convention
82348 − 8/2
93269 − 9/3
102 × 5410 × 1/2 × 4/5
1222 × 3412 × 1/2 × 2/3
10022 × 5240100 × 1/2 × 4/5

Euler’s totient function FAQ

What does Euler’s totient function count?

φ(n) counts the positive integers from 1 through n whose GCD with n is 1. These integers are often called totatives of n.

Why are repeated prime factors used only once?

Each product factor (1 − 1/p) removes integers divisible by one prime p. Reusing the same prime would remove its multiples twice. Exponents matter when reconstructing n, but the Euler product runs over distinct primes.

What is φ(1)?

By standard convention, φ(1) = 1. This makes the totient function multiplicative and corresponds to counting 1 as relatively prime to itself.

What is φ(p) for a prime p?

φ(p) = p − 1. A prime has no positive divisors other than 1 and itself, so every positive integer less than p is coprime to it.

Is φ(n) always even?

φ(n) is even for every integer n greater than 2. Coprimes can be paired as a and n − a; there are no unpaired members when n > 2.

How large a number can this calculator use?

The accepted range is 1 through 1 trillion. The calculator uses optimized trial division and exact BigInt arithmetic. The limit keeps difficult primes and semiprimes from making the page unresponsive.

Is my input private?

Yes. Factoring and arithmetic happen entirely in your browser. This calculator does not upload, save, or add your number to a URL.

Explore more tools