Euler's Totient Calculator
- Factorise 36 into distinct primes: 36 = 2^2 x 3^2. Only the distinct primes matter — the exponents drop out of the formula.
- Euler's product formula takes one factor of (1 - 1/p) for each distinct prime: (1 - 1/2) x (1 - 1/3).
- φ(36) = 36 x 0.5 x 0.6667 = 12 — that many integers from 1 to 36 are coprime to it.
- The totient is the count behind Euler's theorem (a^φ(n) is congruent to 1 mod n for a coprime to n) and behind RSA key sizes; for a prime p it is simply p - 1, since everything below a prime is coprime to it.
This Euler totient calculator finds φ(n), the count of integers from 1 to n that are coprime to n — numbers sharing no factor with n except 1. Type in a number and the calculator returns its totient along with the reasoning behind it. For example, φ(36) = 12, built from the distinct prime factors 2 and 3: 36 × (1 − 1/2) × (1 − 1/3). For a prime p, the answer is simply p − 1, so φ(97) = 96, because every number below a prime is coprime to it. And φ(100) = 40, from the distinct primes 2 and 5.
The method behind the calculator is the standard approach for this calculation: factor n into its distinct primes, then multiply n by (1 − 1/p) for each one. It is the accepted way to compute φ(n) because it follows directly from how the totient is defined, and it scales to large inputs once the prime factors are known. This page does not just hand you a number. It shows the formula, lays out the step-by-step workings for your input, walks through worked examples such as φ(36), φ(97) and φ(100), and lists its sources. You can also see why the totient matters: it sits behind Euler's theorem (a^φ(n) ≡ 1 mod n for a coprime to n) and behind the key arithmetic of the RSA cryptosystem.
Worked examples
φ(36)
Primary result: 12. Full step-by-step working is shown with the result. (36)
| Euler's totient φ(n) | 12 |
| Prime factorisation | 2^2 x 3^2 |
| Share of integers coprime to n | 0.3333 |
φ(97) — a prime
Primary result: 96. Try it with your own numbers in the calculator above. (97)
| Euler's totient φ(n) | 96 |
| Prime factorisation | 97 (prime) |
| Share of integers coprime to n | 0.9897 |
φ(100)
Primary result: 40. Every intermediate value is printed in the worked steps. (100)
| Euler's totient φ(n) | 40 |
| Prime factorisation | 2^2 x 5^2 |
| Share of integers coprime to n | 0.4 |
What the totient counts
Euler's totient function, written φ(n), answers a counting question: among the integers from 1 to n, how many share no factor with n except 1? Two numbers with that property are called coprime. So φ(n) is the size of the coprime crowd below n — the numbers that have nothing in common with n in their prime makeup. This is exactly the quantity an euler totient calculator returns for any n you enter, and understanding what it counts makes the output easier to trust.
Take n = 36. Its distinct prime factors are 2 and 3, and the formula gives 36 × (1 − 1/2) × (1 − 1/3) = 12. The enumeration idea behind that answer is straightforward: walk through 1 to 36 and keep only the numbers not divisible by 2 and not divisible by 3. The survivors are 1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, and 35 — twelve numbers, matching φ(36) = 12. Notice that 25 stays on the list even though it is 5 × 5, because 5 is not a factor of 36; coprimality is about shared factors with n, not about being prime. Notice too that 1 is always counted, since its only factor is 1.
Primes give the cleanest case. For a prime p, φ(p) = p − 1, because every integer below a prime is coprime to it — nothing smaller can divide it. So φ(97) = 96: all 96 numbers from 1 to 96 pass the test. The formula agrees, since 97 × (1 − 1/97) = 96. A second example with two distinct primes: φ(100) = 40, built from the distinct primes 2 and 5 as 100 × (1 − 1/2) × (1 − 1/5).
The totient is not just a counting curiosity. It sits behind Euler's theorem, which states that a^φ(n) ≡ 1 mod n whenever a is coprime to n, and it sits behind the RSA cryptosystem's key arithmetic. That is why the count matters beyond number puzzles: it measures the structure of the numbers that interact cleanly with n.
How to calculate φ(n)
Euler's totient φ(n) counts the integers from 1 to n that are coprime to n — sharing no factor with it except 1. The fastest way to get that count is Euler's product formula, which builds φ(n) from the distinct prime factors of n. The key point: only the distinct primes matter. If a prime divides n, you multiply by (1 − 1/p) exactly once, no matter how many times that prime appears in the factorization. Exponents drop out of the formula entirely.
The formula reads φ(n) = n × (1 − 1/p₁) × (1 − 1/p₂) × … for each distinct prime p that divides n. Take 36. Its prime factorization is 2² × 3², so the distinct primes are 2 and 3 — the exponents of 2 and 3 play no part. Applying the formula: 36 × (1 − 1/2) × (1 − 1/3) = 36 × 1/2 × 2/3 = 12. So φ(36) = 12, meaning exactly 12 of the numbers from 1 to 36 share no factor with 36 other than 1.
A prime is the simplest case. For a prime p, φ(p) = p − 1, because every integer below a prime is coprime to it. So φ(97) = 96: the numbers 1 through 96 all share no factor with 97 except 1, and only 97 itself fails. This is also why the product formula feels natural — a prime has just one distinct prime factor, itself, and 97 × (1 − 1/97) = 96.
Now try 100. Its prime factorization is 2² × 5², so again the distinct primes are 2 and 5. That gives φ(100) = 100 × (1 − 1/2) × (1 − 1/5) = 100 × 1/2 × 4/5 = 40. Notice that 100 has four prime factors counting multiplicity (2, 2, 5, 5) but only two distinct ones, and the formula uses the two. If you are using an Euler totient calculator, the usual workflow is to factor n into distinct primes, then apply one (1 − 1/p) term per prime. The same result can be checked by listing the numbers 1 to n and crossing out multiples of each distinct prime.
This quantity is not just a counting curiosity. The totient sits behind Euler's theorem (a^φ(n) ≡ 1 mod n for a coprime to n) and behind the RSA cryptosystem's key arithmetic, which is why computing φ(n) accurately matters in practice.
Special cases worth knowing
A few inputs to an euler totient calculator follow patterns simple enough to check by hand, and knowing them makes the tool's output easier to trust. The first is the prime case. For a prime p, φ(p) = p − 1, because every integer from 1 to p − 1 shares no factor with p except 1. Take p = 97: the calculator returns φ(97) = 96, and you can see why without any factoring work, since nothing below a prime can divide it. If a result for a prime input ever comes back as anything other than one less than the number, something has gone wrong.
The second case extends the first to prime powers. If n = p^k, the only numbers from 1 to n that are not coprime to n are the multiples of p, and there are p^(k−1) of them. So φ(p^k) = p^k − p^(k−1). A prime power behaves almost like a prime, but not quite: the count is smaller than p^k − 1 by exactly the number of multiples of p below it. This is the rule to keep in mind whenever an input looks like 8, 9, 25, or 27 rather than a plain prime.
The third case is the one that does most of the work behind the scenes: the totient is multiplicative over coprime arguments. If a and b share no common factor, then φ(a × b) = φ(a) × φ(b). That is why a composite input can be handled one prime factor at a time. For 36, the distinct primes are 2 and 3, and φ(36) = 12, which comes from 36 × (1 − 1/2) × (1 − 1/3). For 100, the distinct primes are 2 and 5, and φ(100) = 40. In both examples only the distinct primes matter — the exponents affect the size of the number, not the list of primes you plug in.
These cases also explain why the totient matters beyond a single answer. It sits behind Euler's theorem, which states that a^φ(n) ≡ 1 mod n whenever a is coprime to n, and it sits behind the key arithmetic of the RSA cryptosystem. Both uses depend on the counting rule being exact, so the special cases above are worth a quick mental check before you rely on a result.
A practical habit: when you enter a number, ask which case it fits. A prime should give one less than itself; a prime power should give p^k − p^(k−1); a product of coprime pieces should give the product of their totients. If the number matches none of these cleanly, factor it into distinct primes and let the calculator do the rest.
- Prime p: φ(p) = p − 1, so φ(97) = 96.
- Prime power p^k: φ(p^k) = p^k − p^(k−1).
- Coprime a and b: φ(a × b) = φ(a) × φ(b).
- φ(36) = 12 from the distinct primes 2 and 3; φ(100) = 40 from the distinct primes 2 and 5.
Where the totient is used
Euler's totient is not just a number to compute for its own sake. It shows up wherever you need to know how many values are coprime to n, and that count turns out to matter in several very different areas of mathematics and computing.
The most direct use is Euler's theorem, which states that a^φ(n) ≡ 1 mod n whenever a is coprime to n. This is the engine behind modular exponentiation shortcuts: if you know φ(n), you can reduce a huge exponent modulo φ(n) before doing the power, which makes otherwise enormous calculations tractable. For example, since φ(100) = 40, any base coprime to 100 raised to the 40th power lands back at 1 modulo 100. That kind of reduction is the everyday workhorse of number theory and cryptography.
The RSA cryptosystem builds its key arithmetic on the totient. Key generation depends on knowing φ(n) for a modulus n that is the product of two large primes, and the security of the scheme rests on the fact that computing that totient is hard without knowing the prime factors. This is where an euler totient calculator earns its keep as a learning tool: you can plug in a small composite, see the totient fall out, and watch how the exponent arithmetic lines up. The same logic that makes φ(36) = 12 — from the distinct prime factors 2 and 3, via 36 × (1 − 1/2) × (1 − 1/3) — is the logic RSA scales up to numbers with hundreds of digits.
Counting also comes up in more elementary settings. The totient counts the fractions between 0 and 1 with denominator n that are already in lowest terms, so φ(n) tells you how many reduced fractions sit at that denominator. And for a prime p, φ(p) = p − 1, because every integer below a prime is coprime to it — φ(97) = 96, for instance. That clean value feeds into the theory of primitive roots, where the totient of p − 1 governs how many generators exist modulo p.
A few of the recurring applications, in short:
- Euler's theorem — reducing exponents modulo φ(n) for a coprime to n
- RSA key generation — the totient of the modulus drives the key arithmetic
- Counting fractions in lowest terms — φ(n) fractions with denominator n reduce no further
- Primitive roots — φ(p) = p − 1 for prime p, and the totient of p − 1 counts generators
FAQs
What is Euler's totient function?
Euler's totient function, written φ(n), counts how many integers from 1 to n are coprime to n. In other words, it gives the size of the multiplicative group modulo n. Two numbers are coprime when their only common divisor is 1, so φ(n) tells you how many numbers below n share no factor with n.
How do you calculate φ(36)?
Factor 36 as 2² × 3². The product formula uses only the distinct primes 2 and 3: φ(36) = 36 × (1 − 1/2) × (1 − 1/3). Working it through, 36 × 1/2 = 18, and 18 × 2/3 = 12. So φ(36) = 12, meaning 12 of the integers from 1 to 36 are coprime to 36.
What is φ of a prime number?
For a prime p, φ(p) = p − 1. Every positive integer smaller than a prime is coprime to it, since the prime's only divisors are 1 and itself. For example, φ(97) = 96, because all 96 integers from 1 to 96 share no common factor with 97.
Do the exponents in the factorisation matter?
No. Only the distinct prime factors enter the product formula, so repeated primes are counted once. In 36 = 2² × 3², the factor 2² contributes the same factor as a single 2 would, and the same holds for 3². The exponents change the value of n, not which factors appear in the product.
Where is the totient used in cryptography?
RSA key generation works modulo φ(n), where n is the product of two primes. Euler's theorem is the reason decryption reverses encryption: it guarantees that raising to the right exponent modulo n undoes the encryption step. The totient is central to building the keys and to why the scheme works.
What is φ(100)?
φ(100) = 40. The distinct prime factors of 100 are 2 and 5, so the product formula gives 100 × (1/2) × (4/5). First 100 × 1/2 = 50, then 50 × 4/5 = 40. So 40 of the integers from 1 to 100 are coprime to 100.