Advanced

Euler's Totient (Phi) Calculator

Euler's totient φ(n) counts how many integers from 1 to n share no common factor with n other than 1.
A positive integer (n ≥ 1)
Euler totient φ(n)
12

Count of integers in 1..n coprime to 36

φ(n)
12
Distinct prime factors
2, 3
Coprime ratio φ(n)/n
0.3333

12

coprime

Coprime to n

33.3%

Sharing a factor

66.7%

Step by step
  1. 1

    Distinct prime factors of n

    2, 3
  2. 2

    Apply product formula φ(n) = n × Π(1 − 1/p)

    36 × (1 − 1/2) × (1 − 1/3) = 12
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

How does this calculator work?

Euler's totient φ(n) counts the integers from 1 to n that are coprime to n. Factor n into its distinct primes p and compute φ(n) = n · Π(1 − 1/p). The coprime ratio φ(n)/n equals that product and gives the chance a random integer below n is coprime to n.

Formula
φ(n) = n · Π (1 − 1/p) over distinct primes p dividing n
How this is calculated

Enter a single positive integer n (n ≥ 1). The calculator factors n by trial division, finding each distinct prime p that divides it. Repeated prime factors are collapsed, so only the set of distinct primes matters for the totient.

Starting from φ = n, the result is multiplied by (1 − 1/p) for every distinct prime p, which is implemented as φ = φ − φ/p to avoid floating-point drift; the final value is rounded to the nearest integer. This is the product formula φ(n) = n · Π(1 − 1/p), which holds because the totient is multiplicative over coprime prime powers. The coprime ratio φ(n)/n equals that same product and represents the probability that a random integer in 1..n is coprime to n.

Edge cases: φ(1) = 1 by convention, and a prime n returns φ(n) = n − 1 with itself as the only prime factor. Inputs must be whole positive numbers; non-integers, values below 1, or extremely large n (above 10^12) are rejected. Outputs are pure counts and have no physical units.

Frequently asked questions

By convention φ(1) = 1, since 1 is counted as coprime to itself and there are no prime factors to reduce the count.

A prime p shares no factor with any of 1, 2, …, p − 1, so all p − 1 of those integers are coprime to it, leaving only p itself excluded.

No. Only the distinct primes dividing n appear in the product Π(1 − 1/p); their multiplicities are absorbed into the leading factor n.

Also known as

euler totient calculator
phi function calculator
totient function
euler phi
coprime count
euler's totient

APA

TG we-Calculate Editorial Team. (2026). Euler's Totient (Phi) Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/euler-totient-calculator

Chicago

TG we-Calculate Editorial Team. "Euler's Totient (Phi) Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/euler-totient-calculator.

IEEE

TG we-Calculate Editorial Team, "Euler's Totient (Phi) Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/euler-totient-calculator

BibTeX

@misc{wecalculate_euler_totient_calculator, title = {Euler's Totient (Phi) Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/euler-totient-calculator}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?