Euler Totient Calculator
This calculator works out Euler's totient, written phi(n), which counts how many whole numbers from 1 up to n share no factor with n other than 1, that is, how many integers in that range are coprime to n. The totient is one of the building blocks of number theory and sits behind RSA encryption, where it fixes the size of the group used for encryption and decryption exponents, and behind other results in modular arithmetic. You enter a whole number n from 2 up to a billion into the single input field. The calculator finds the distinct prime factors of n and applies the formula phi(n) equals n multiplied by (1 minus 1 over p) for every distinct prime p dividing n, rather than testing each number below n for a common factor, which keeps it fast even for very large values. It returns three figures: the totient itself, shown as phi(n) equals the result, the count of distinct prime factors n has, and how many integers up to n are not coprime to n. For example, entering 36, which factorises as 2 squared times 3 squared, returns a totient of 12, two distinct prime factors, and 24 integers that are not coprime to 36. The page below sets out the formula in full, walks through that worked example, and answers common questions about what the totient counts and why it underpins RSA. It suits students checking coursework, programmers implementing cryptographic or combinatorial code, and anyone curious about number theory, and because the result is computed exactly from the prime factorisation, there is no rounding or estimation involved.
The formula
Euler’s totient is phi(n) = n times the product over each distinct prime p dividing n of (1 minus 1/p). Equivalently, for each distinct prime you multiply by (p minus 1) and divide by p.
Worked example
36 = 2 squared times 3 squared, so phi(36) = 36 times (1 minus 1/2) times (1 minus 1/3) = 36 times 1/2 times 2/3 = 12. Enter 36 to confirm.
Frequently asked questions
What does the totient count?
The whole numbers from 1 to n that are coprime to n, meaning their greatest common factor with n is 1.
What is phi of a prime p?
p minus 1, because every number from 1 to p minus 1 is coprime to a prime.
Why does RSA use the totient?
The totient of the modulus sets the order of the multiplicative group, which determines the encryption and decryption exponents.
Who this calculator is for
This calculator is for students, programmers and anyone exploring number theory.
What this calculator assumes
- You enter a whole number within the stated range.
- The exact integer algorithm is used.
- Very large results are shown grouped for readability.
Formula and sources
Related calculators
- Prime Factorization Calculator: break a number into prime factors.
- LCM Calculator: lowest common multiple.
- GCF Calculator: greatest common factor.