numvana

Euler's Totient Function Calculator

Find φ(n), the count of integers from 1 to n that are coprime to n, along with n's distinct prime factors.

φ(n) — integers from 1 to n coprime to n
12
Distinct prime factors of n
2, 3

How it works

Euler's totient function φ(n) counts how many integers from 1 to n share no common factor with n other than 1 (are 'coprime' to n). It's computed from n's prime factorization: if n = p1^a1 × p2^a2 × ... × pk^ak, then φ(n) = n × (1 − 1/p1) × (1 − 1/p2) × ... × (1 − 1/pk) — one factor per DISTINCT prime that divides n, regardless of how many times it divides it.

This calculator finds those distinct prime factors the same way this site's prime-factorization calculator does, then folds each one into the running totient as it's found. For a prime number p itself, this simplifies to the well-known φ(p) = p − 1, since every one of 1 through p−1 is automatically coprime to a prime.

By convention φ(1) = 1 — there's exactly one integer (1 itself) in the range from 1 to 1, and it's trivially coprime to everything.

FAQ

What is the totient function actually used for?

It's foundational to number theory and cryptography. RSA encryption, for example, relies on Euler's theorem (which the totient function is central to) to make the encrypt/decrypt key pair work, and this site's modular-inverse calculator computes a related quantity — a private exponent in RSA is the modular inverse of the public exponent with respect to φ(n).

Why does only the DISTINCT prime factors matter, not how many times each one appears?

Because each (1 − 1/p) factor already accounts for every multiple of p being removed from the coprime count, at every power — once p is excluded, p², p³, and so on are automatically excluded too, since they're already multiples of p. Repeating the same (1 − 1/p) factor again for a higher power of the same prime would double-count that exclusion and give a wrong (too-small) result.

Related calculators