Euler's Totient Calculator
What this Euler’s totient calculator finds
Euler's totient function, written φ(n), answers a very specific counting question: among the positive integers below n, how many are coprime to n? Two numbers are coprime when their greatest common divisor is 1, which means they share no prime factor. That sounds abstract at first, but it shows up all over number theory. Totients describe how many residues are invertible modulo n, they help explain the behavior of modular arithmetic cycles, and they appear in topics ranging from fraction reduction to RSA-style cryptography. This calculator turns that idea into a fast one-input computation. You enter a positive integer n, and the page returns the exact value of φ(n).
The totient result is always a whole-number count, not a percentage, probability, or measurement. If you enter 12 and get 4, there are four positive integers less than 12 that share no factor with 12 other than 1: 1, 5, 7, and 11. If you enter a prime such as 13, the answer is 12 because every positive integer from 1 through 12 is coprime to 13. At the opposite extreme, an input with several small prime factors usually has a much smaller totient because more candidates are excluded.
What the totient input n means
Euler’s totient calculator has one input because φ(n) is defined from one integer n. Enter any positive whole number at least 1. Decimals do not make sense here because φ(n) is defined for integers. Negative values and zero are also outside the intended domain. The number you enter is unitless: its divisibility structure, rather than any physical unit, determines the output.
The smallest edge case for the totient is n = 1. The calculator returns 1, matching the standard convention in number theory. For every value greater than 1, interpret the answer as the count of positive integers strictly less than n that are relatively prime to n. To see the definition directly, list the integers from 1 to n − 1 and cross out every value sharing a prime factor with n; the remaining values are counted by φ(n).
What “coprime” means for φ(n)
The coprime test behind Euler’s totient is a greatest-common-divisor test. A number a contributes to φ(n) exactly when gcd(a, n) = 1. If n = 10, any number divisible by 2 or 5 is not coprime to 10 because those are 10’s prime factors. Among the integers below 10, the valid values are 1, 3, 7, and 9, so φ(10) = 4. The calculator reaches this count efficiently, but the underlying rule remains simple: reject a shared factor and count a gcd of 1.
This coprime viewpoint explains why prime factorization matters more than raw size for the totient. The number 29 is larger than 28, but φ(29) is 28 because 29 is prime, while φ(28) is only 12 because 28 has the prime factors 2 and 7. The result depends less on how large n is than on which distinct primes divide it.
How the Euler totient formula works
The direct definition of φ(n) is a count, but this Euler totient calculator uses the efficient prime-factor formula. If the distinct prime divisors of n are p1, p2, …, pk, then the totient is
That product runs over the distinct primes dividing n. Distinct is the key word. If a prime factor repeats, it still appears only once in the product. For example, 12 factors as 22 × 3, but the formula uses only 2 and 3 once each: φ(12) = 12(1 − 1/2)(1 − 1/3) = 4. Repeated powers matter when you factor the number, but they do not create new exclusion rules. A number that shares factor 2 with 12 is already eliminated; having another factor 2 in 12 does not eliminate it twice.
When the factorization is written explicitly as
the same totient formula becomes
For Euler’s totient, start with n and reduce it by the share excluded by each distinct prime factor. Every prime p removes the fraction of candidates that are multiples of p. The calculator searches for prime divisors, removes every repeated occurrence of each divisor, and updates a running φ(n) value. That factor-based approach avoids individually testing every integer below n.
Worked example: finding φ(12)
This Euler totient example starts with n = 12. The positive integers below 12 are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, and 11. Since 12 = 22 × 3, any multiple of 2 or 3 must be rejected. That eliminates 2, 3, 4, 6, 8, 9, and 10. The survivors are 1, 5, 7, and 11, so the count is 4. Therefore, φ(12) = 4.
The factor formula gives the same answer more quickly:
φ(12) = 12(1 − 1/2)(1 − 1/3) = 12 × 1/2 × 2/3 = 4.
This shows why the totient formula is efficient. Once the distinct prime factors are known, the primes 2 and 3 identify exactly which values fail the coprime test; there is no need to test every candidate separately.
Second Euler totient example: finding φ(36)
For a second totient calculation, try n = 36. A common first instinct is to think the answer should be close to 36 because the number is large, but factorization matters more than size. Since 36 = 22 × 32, the distinct prime factors are still just 2 and 3. Any number below 36 that is divisible by 2 or by 3 is excluded. The formula gives
φ(36) = 36(1 − 1/2)(1 − 1/3) = 36 × 1/2 × 2/3 = 12.
So only 12 integers below 36 are coprime to 36. That result is much smaller than 36 because the filters “multiple of 2” and “multiple of 3” remove a large share of the candidates. This example is a helpful reminder that repeated powers do not add new distinct filters, but the presence of small prime factors can shrink the totient dramatically.
Quick Euler totient comparison examples
These φ(n) examples compare how different prime factorizations change the number of coprime integers below an input.
| n | Prime factorization | φ(n) | Why the result looks that way |
|---|---|---|---|
| 8 | 23 | 4 | Only the multiples of 2 are excluded, so exactly half of the numbers below 8 survive. |
| 10 | 2 × 5 | 4 | Multiples of 2 and 5 are removed, leaving 1, 3, 7, and 9. |
| 13 | prime | 12 | Every positive integer below a prime is coprime to it. |
| 18 | 2 × 32 | 6 | The distinct filters are still 2 and 3, so many candidates are eliminated. |
| 30 | 2 × 3 × 5 | 8 | Three small prime factors exclude most numbers below 30. |
In these totient values, 13 has a much larger result than 18 even though the inputs are close. The difference comes from prime-factor structure, not from magnitude alone.
How to interpret an Euler totient result
When the Euler totient calculator displays phi(30) = 8, it means there are eight invertible residue classes modulo 30 among the positive integers below 30. In modular arithmetic, these are the values with multiplicative inverses modulo 30. For Euler's theorem, the result is the exponent in aφ(n) ≡ 1 mod n whenever gcd(a, n) = 1. For reduced fractions, φ(n) is the number of numerators from 1 through n − 1 that are already in lowest terms over denominator n.
The totient also gives useful intuition about an input’s factorization. Prime numbers have the largest possible totient relative to their size because nothing below them shares a factor with them. Numbers built from several small primes have much smaller totients because many candidates fail the gcd test. A large jump or drop between nearby inputs is therefore usually a genuine consequence of changed prime factors, not instability in the calculation.
One interpretation detail matters: φ(n) counts qualifying integers rather than displaying them. The calculator result box gives the count, not a full list of coprime values. For small inputs, you can make the list manually by checking gcd(k, n) = 1 from 1 through n − 1, or use the mini-game below to practice recognizing the survivors.
Euler totient assumptions, limitations, and sanity checks
This Euler totient calculator is exact for positive integer inputs, but it is not intended for symbolic algebra, fractions, decimals, or negative values. Very large integers can take longer in a browser because factor searching still examines possible divisors. For n greater than 1, the result should always be an integer from 1 through n − 1. A non-integer result in hand work signals an error in the factorization or product step.
Useful totient checks come directly from familiar factor patterns. For a prime input, φ(n) must be one less than the input. For a power of two, exactly half the positive integers below it are odd, so φ(2k) = 2k−1. For an input with several distinct small primes, the answer should be noticeably smaller than the input. These checks help verify the factor logic.
- Check integrality: φ(n) must be a whole number.
- Check prime inputs: if n is prime, the answer must be n − 1.
- Check factor logic: adding distinct prime factors usually lowers the surviving share.
Used this way, the calculator is a quick confirmation of the coprime-counting logic behind Euler’s totient function.
Mini-game: Coprime Orbit
Want the definition to feel more intuitive instead of purely symbolic? Coprime Orbit turns the same idea behind φ(n) into a fast visual challenge. Each wave places a target value n in the center of the canvas and arranges the numbers below it around an orbit. Your job is to click only the numbers that are coprime to n. The HUD shows the target count, your streak, and the remaining time, while later waves speed up, reverse direction, or switch to prime-heavy rounds. The game is optional and separate from the calculator itself, but it is designed to make the coprime filter behind the totient function feel immediate.
Tip: when n has several small prime factors, fewer orbiting numbers survive the coprime test, which means φ(n) drops.
