Skip to main content
Calcimator

Euler's Totient Calculator

Calculate Euler's totient function phi(n) — the count of integers from 1 to n that are coprime to n.

About this calculator

Euler's totient function phi(n) counts how many whole numbers from 1 up to n share no common factor with n other than 1, and this engine reaches that count without generating a single one of those numbers directly. It works from n's prime factorization: starting with a running total equal to n, every distinct prime that divides n knocks a (1 minus 1 over p) factor out of that total, which is the standard multiplicative identity behind phi. The trial-division search that finds those primes only needs to check candidates up to the square root of n, so even at the input's ceiling of one million it finishes in a small, bounded number of steps rather than testing a million candidates one at a time. Two of the outputs report essentially the same fact from different angles: phi(n) and Coprime Count are numerically identical, because counting the coprimes to n and evaluating phi(n) are the same operation by definition — the second field exists to name the result by what it means, not to add new information beyond the first.

For a prime p, phi(p) is always p minus 1, since every smaller positive integer is automatically coprime to a prime — so the phi(n)/n ratio for a prime gets closer and closer to 1 as the prime grows (phi(7)/7 is 0.857, phi(997)/997 is 0.999) without ever actually reaching it for any finite prime; the ratio only equals exactly 1 at n = 1, a special case the engine handles on its own and which is not itself prime. The ratio shrinks toward zero for numbers built from several small repeated prime factors instead. A fractional entry like 12.7 is silently floored to 12 before anything else runs, and n is clamped between 1 and 1,000,000 regardless of what the field allows you to type.

Inputs

Results

phi(n)

4

Coprime Count4
phi(n)/n Ratio0.3333
How to Use This Calculator
  1. Enter n.
  2. Review the phi(n) result.
  3. Use Coprime Count and phi(n)/n Ratio to inform your decision.
  4. Use the chart to visualize the results and explore different scenarios by adjusting inputs.

How the result changes with n

nphi(n)
62
96
186
308

What each input means

n
Positive integer to compute phi(n) for

How this is calculated

Worked example, using the default values

  1. Identify Input Parameters
    n = 12 = 1 input(s) provided
  2. Calculate phi
    phi
    4 = 4
  3. Calculate Coprime Count
    Coprime Count
    4 = 4

Engine last updated . Checked against 4 independently-derived tests — how we verify calculators. Built by Paul Gunder, a software engineer, not a licensed financial, medical, or legal professional.

Frequently Asked Questions

Why are phi(n) and Coprime Count always the same number?

Because they measure the identical thing. Phi(n) is defined as the count of integers from 1 to n that share no common factor with n, and Coprime Count is that same tally under a plainer label — the calculator does not run a second, independent calculation to produce it.

How does the calculator find phi(n) so fast for a large n?

It only searches for prime divisors up to the square root of n rather than testing every integer up to n itself, then applies the standard identity that removes a (1 minus 1 over p) factor for each distinct prime found. That keeps even the one-million ceiling fast to evaluate.

What does a phi(n)/n ratio close to 1 tell me?

It almost always means n is a large prime. For a prime p, phi(p) is p minus 1, so the ratio climbs toward 1 as the prime gets bigger — phi(997)/997 is 0.999 — without ever reaching exactly 1 for any finite prime. Ratios noticeably below 1 point to n being built from several small repeated prime factors instead.

What happens if I type a decimal like 12.7?

It is floored to 12 before the totient calculation runs, with no rounding warning shown on the page. Entering 12.9 produces exactly the same result as entering 12, since both are truncated to the same integer before the prime search begins.

The questions that sit next to this one — chosen by subject, including calculators filed under a different category.

More in Math & Statistics.