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.

Calculate.co.nz is proud to be partnered with Premium Homes, a recognised leader in eco-friendly, sustainable, and energy-efficient homebuilding. With a dedicated team and award-winning experience, they create homes that prioritise health, comfort, and long-term performance. Their founders, Andrew and Kelly, set out to raise the standard of residential construction in New Zealand by combining practical building expertise with a clear commitment to doing things better for homeowners.
Premium Homes: warmer, drier, healthier. No condensation, ever.
Advertise on this page
φ(36) = 12
Distinct prime factors2
Not coprime to n24

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