|

Euler Phi Function Calculator

Euler Phi Function Calculator (Totient)

Work out Euler’s totient φ(n): how many numbers from 1 to n share no factor with n — free, in your browser, nothing uploaded. The tool factorises n first, then applies the product formula step by step, so you can see exactly where the answer comes from.

Pick a number, say 36. Now count how many of the numbers from 1 to 36 share no factor with it — no common divisor bigger than 1. The answer is 12, and that count has a name: Euler's totient function, written φ(n) and pronounced "fee of n." An Euler phi function calculator works that count out for you, and the calculator at the top of this page does it the honest way: it factorises your number into primes first, then applies Euler's product formula one prime at a time, showing every step. That matters because the totient is almost impossible to count by hand for large n, yet it sits underneath some very practical mathematics — most famously the RSA encryption that secures much of the internet, where the whole system rests on the fact that φ(n) is easy to compute if you know the factors of n and extremely hard if you do not.

Direct answer: For n = 36, phi(36) = 12, and for n = 100, phi(100) = 40.

The totient function, also called the Euler totient or Euler phi function, answers a question about coprime numbers: two numbers are coprime (or relatively prime) when their greatest common divisor is 1. Among 1 to 36, the numbers coprime to 36 are 1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, and 35 — count them and there are 12, matching φ(36) = 12. Notice 25 is on the list even though it is not prime: coprime means sharing no factor with 36, and 25 = 5² shares nothing with 36 = 2² × 3². That distinction — coprime is a relationship between two numbers, not a property of one number — is the first thing to get straight, and the product formula below is built entirely on it.

What the Euler Phi Function Is

Euler's totient φ(n) counts the integers from 1 to n that are coprime to n. The definition is a counting definition, but nobody computes it by counting, because Euler found a formula. If n factorises into primes as n = p₁^a₁ × p₂^a₂ × …, then φ(n) = n × (1 − 1/p₁) × (1 − 1/p₂) × …, using each distinct prime factor exactly once, whatever its power. For 36 = 2² × 3², the distinct primes are just 2 and 3, so φ(36) = 36 × (1 − 1/2) × (1 − 1/3) = 36 × 1/2 × 2/3 = 18 × 2/3 = 12. The calculator shows precisely those steps, in that order, for whatever n you enter.

The formula has a reading that makes it feel less like magic. Start with all n numbers from 1 to n. The factor (1 − 1/2) throws away the half of them that share the factor 2. The factor (1 − 1/3) throws away a third of what remains — those sharing the factor 3 — and because the two throwings-away are independent in exactly the way the multiplication describes, what survives is exactly the numbers sharing neither factor, which is the coprime count. This is also why powers do not matter: 36 and 12 = 2² × 3 have the same distinct primes, but different sizes; φ(12) = 12 × 1/2 × 2/3 = 4, and indeed 1, 5, 7, 11 are the four numbers up to 12 coprime to 12. The power of each prime changes n itself, which is in the formula, but the set of "bad" primes is what the factors (1 − 1/p) encode.

A few special cases anchor intuition. If p is prime, every number from 1 to p − 1 is coprime to p, so φ(p) = p − 1: φ(7) = 6, φ(13) = 12. If n is a prime power p^a, then φ(n) = p^a − p^(a−1): φ(8) = 8 − 4 = 4 (the odd numbers 1, 3, 5, 7), and φ(9) = 9 − 3 = 6. And φ(1) = 1 by convention, since gcd(1, 1) = 1. The totient is also multiplicative in a specific, careful sense: when m and n are coprime to each other, φ(m × n) = φ(m) × φ(n). That is what lets big totients be built from small ones — and it is "when coprime" that does the work, because φ(2 × 2) = φ(4) = 2, which is not φ(2) × φ(2) = 1. The calculator's factorisation steps make all of this visible rather than leaving the formula as a black box.

How to Use the Calculator

Using the tool takes a few seconds. Follow these steps:

  1. Enter a whole number n, from 1 to 10,000,000. The live test uses 36.
  2. Press "Calculate φ(n)".
  3. Read the result, the prime factorisation of n, and the step-by-step product formula, where each step multiplies by (1 − 1/p) for one distinct prime factor.

That is the whole interaction. The interesting part is reading the steps: the factorisation tells you which primes are involved, and the multiplication steps show the count shrinking — 36 becomes 18 after the prime 2 is applied, then 12 after the prime 3 — each intermediate value being a whole number, never a fraction, because at each step the current value is still divisible by the next prime. If your n is prime, the factorisation is n itself and the single step gives n − 1, which is a tidy way to confirm a number's primality for small values, though dedicated primality tests are the right tool for large ones.

Bar chart showing phi(36) = 12 and phi(100) = 40

Worked Examples

Example 1: φ(36) = 12, the live test

Enter 36. The factorisation is 36 = 2^2 × 3^2. Distinct primes: 2 and 3. The product formula runs: start with 36; multiply by (1 − 1/2) to get 36 × 1/2 = 18; multiply by (1 − 1/3) to get 18 × 2/3 = 12. So φ(36) = 12. Cross-check against the definition by listing: the numbers from 1 to 36 coprime to 36 are 1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35 — twelve of them. The list has a pattern worth seeing: the numbers repeat their coprime residues every 36, and within any block of 36 consecutive integers exactly 12 are coprime to 36, which is why φ appears in results about fractions in lowest terms and about periodic patterns.

Example 2: φ(100)

Enter 100. Factorisation: 100 = 2^2 × 5^2. Distinct primes 2 and 5. Steps: 100 × (1 − 1/2) = 50; 50 × (1 − 1/5) = 50 × 4/5 = 40. So φ(100) = 40. This one has a lovely interpretation: φ(100) counts the fractions between 0 and 1 with denominator 100 that are already in lowest terms — 40 of the 99 candidate numerators survive, 1, 3, 7, 9, 11, and so on up to 99, because any numerator sharing 2 or 5 with 100 would cancel. It also counts the two-digit endings, from 01 to 99 plus 00 handled by convention, that can appear in cycles of powers: the last two digits of 7^k, for example, cycle with a period that divides φ(100) = 40, a consequence of Euler's theorem below.

Example 3: A prime and a prime power

Enter 13: the factorisation is just 13, the single step gives 13 × (1 − 1/13) = 12, so φ(13) = 12. Enter 27: 27 = 3^3, one distinct prime, and the step gives 27 × (1 − 1/3) = 18, so φ(27) = 18 — the numbers from 1 to 27 that are not multiples of 3, which are indeed two-thirds of 27. Comparing the two shows the formula's logic in miniature: what matters is which primes divide n, and how big n is — not how many times each prime appears, except through n itself.

Example 4: φ(720)

Enter 720 for a bigger workout. Factorisation: 720 = 2^4 × 3^2 × 5. Three distinct primes, three steps: 720 × (1 − 1/2) = 360; 360 × (1 − 1/3) = 240; 240 × (1 − 1/5) = 192. So φ(720) = 192. Doing that by listing the numbers coprime to 720 would mean checking 720 numbers against three primes by hand; the formula needs one factorisation and three multiplications. That gap — trivial with factors, tedious without — widens fast as n grows, and it is the entire basis of the cryptography application.

Euler's Theorem and Why φ Matters

The totient is famous because of Euler's theorem: if a and n are coprime, then a^φ(n) leaves remainder 1 when divided by n — in modular arithmetic notation, a^φ(n) ≡ 1 (mod n). Fermat's little theorem is the prime special case: a^(p−1) ≡ 1 (mod p). This is not an abstract decoration. It means powers cycle with a rhythm governed by φ(n), which is how enormous exponents can be reduced to small ones in modular arithmetic, and it is the mathematical hinge of RSA encryption: messages are raised to powers modulo a large n, and decryption works because φ(n) lets the exponent be unwound — but only by someone who knows φ(n), and computing φ(n) for the RSA modulus requires its prime factors, which are kept secret because factorising a several-hundred-digit product of two primes is computationally infeasible with known methods.

More everyday appearances exist too. The totient counts the possible generators in some cyclic structures, appears in the theory of Farey sequences (the count of fractions between 0 and 1 with denominators up to n is built by summing totients), and governs which regular polygons can be constructed and which fractions have purely repeating decimal expansions of a given length. Even the simple game of "reduce this fraction" is totient territory: of the fractions with denominator n, exactly φ(n) of those between 0 and 1 are already reduced.

Reading the Steps: What Each Line Means

It is worth slowing down over the calculator's output once, because the step format teaches the structure of the function. The factorisation line separates two ideas that novices merge: the full factorisation, powers included, describes n itself, while the list of distinct primes describes which proportions get removed. The multiplication steps then pair them in order. Each step's result is a whole number, and that is guaranteed, not luck: when the step for prime p runs, the current value still contains p as a factor, because earlier steps only ever divided out different primes. So 36 ÷ 2 = 18 and 18 ÷ 3 = 6 with the multipliers (p − 1) applied alongside give clean integers at every line. If you ever compute a totient by hand and meet a fraction mid-calculation, you have either repeated a prime or applied the formula in a broken order — a useful self-check. The final number also passes a rough sanity test: φ(n) is always even for n above 2, it is always less than n for n above 1, and it equals n − 1 exactly when n is prime. None of those checks proves an answer, but each can catch a slip, and the tool's step display makes all three easy to apply.

Common Mistakes

The first common mistake is feeding the powers into the product formula — multiplying by (1 − 1/p) once per prime factor occurrence instead of once per distinct prime. For 36 that error gives 36 × 1/2 × 1/2 × 2/3 × 2/3 = 4, not 12. The calculator's factorisation display, with distinct primes listed separately from the factorisation, is designed to prevent exactly this. The second mistake is thinking coprime means prime: 25 is coprime to 36 and 1 is coprime to everything, while 6 is not coprime to 9 despite neither being prime. The third is applying the multiplicative rule φ(mn) = φ(m)φ(n) when m and n share a factor; it holds only for coprime m and n. The fourth is expecting φ(n) to behave smoothly — it does not: φ(97) = 96 for the prime 97, while φ(96) = 32, so neighbours can have wildly different totients. The fifth is confusing the totient with the count of prime factors or with n's number of divisors, which are different functions with different formulas.

Limits: What This Tool Does and Does Not Do

This tool computes φ(n) exactly for whole numbers n from 1 to 10,000,000, by trial-division factorisation and the product formula, showing the factorisation and every multiplication step. The cap exists because trial division up to the square root of n is what keeps the factorisation instant in a browser; beyond ten million, dedicated factoring tools with stronger methods are the right choice, and the tool says so rather than spinning. It does not compute the totient of a fraction or a negative number (the function is defined on positive whole numbers), it does not list the coprime numbers themselves (for small n the article examples show how they look, but listing them for n in the millions would be a wall of numbers), and it does not perform the modular exponentiation of Euler's theorem — it computes φ, the ingredient that theorem needs. Within its cap, the arithmetic is exact whole-number work, and every step shown is a step actually performed.

Privacy: Your Numbers Stay in Your Browser

Every number you enter into this Euler phi function calculator stays in your browser. Nothing is uploaded to a server, nothing is stored, and there is no account to create. The calculation runs entirely on your own device. Closing the page removes your inputs, and no one else sees them. This browser-only design is the same principle behind the other free tools on Your Smart Kit: a simple tool that does one job well, keeps your data private, and gives an answer you can check.

Frequently Asked Questions

What is Euler's totient function?

It is the count of integers from 1 to n that are coprime to n — sharing no common factor with n except 1. It is written φ(n), called the Euler phi function or totient function, and computed by φ(n) = n × (1 − 1/p) over each distinct prime factor p of n.

What is φ(36)?

  1. Since 36 = 2² × 3², the formula gives 36 × (1 − 1/2) × (1 − 1/3) = 36 × 1/2 × 2/3 = 12. The calculator shows the factorisation and both multiplication steps.

Why do the prime powers not appear in the formula?

Because the factor (1 − 1/p) for a prime p removes exactly the proportion of numbers sharing that prime, and that proportion does not depend on how many times p divides n. The power still matters through n itself: φ(27) = 27 × 2/3 = 18 differs from φ(3) = 2.

What is φ of a prime number?

If p is prime, φ(p) = p − 1, because every number from 1 to p − 1 is coprime to p. So φ(13) = 12 and φ(97) = 96.

Where is the totient function used?

Under Euler's theorem in modular arithmetic, in RSA public-key cryptography (where its computation requires knowing the prime factors of the modulus), in counting fractions in lowest terms, in Farey sequences, and in the theory of repeating decimals and cyclic groups.

What is the largest n this calculator accepts?

10,000,000. That cap keeps the browser factorisation effectively instant; it is stated in the tool, and larger inputs get a clear message rather than a long wait.

Related Tools on Your Smart Kit

If you found the Euler phi function calculator useful, you may also like the other free calculators on Your Smart Kit, including the Angle of Complex Number Calculator for argument and modulus work, the cosh calculator for hyperbolic functions defined from exponentials, and the Fibonacci series calculator for exact whole-number sequences. Each runs in your browser, free, with no sign-up, and each is built on the same principle: a simple tool that does one job well, keeps your data private, and gives an answer you can check. Try the Euler phi function calculator at the top of this page with a number of your own, factorise it, and watch the coprime count fall out of three lines of arithmetic.

How do I check phi(36) = 12 without counting to 36?

Use the prime factors, not a count. For 36 = 2^2 times 3^2, the distinct primes are 2 and 3, so phi(36) = 36 times (1 - 1/2) times (1 - 1/3) = 36 times 1/2 times 2/3 = 12. The tool's live steps are 36 to 18, then 18 to 12, which match that product in order.

Why does phi(100) = 40 even though 100 is larger than 36?

Phi depends on the distinct primes, not on size alone. For 100 = 2^2 times 5^2, the live steps are 100 to 50, then 50 to 40, so phi(100) = 40. A larger number with few distinct primes can have a larger totient than a smaller number with many small prime factors, because each distinct prime removes only its own share.

What is the most common totient mistake with prime powers?

The mistake is applying the factor for a prime once for every power, for example using (1 - 1/2) twice for 36. The tool applies each distinct prime once: 2 once and 3 once for 36, and 2 once and 5 once for 100. Powers change the factorisation line, but they do not add extra factors to the product.

Quick-reference table for the live tests

Input nPrime factorisationLive stepsTool result
362^2 times 3^236 to 18, then 18 to 12phi(36) = 12
1002^2 times 5^2100 to 50, then 50 to 40phi(100) = 40

Worked example with the live test figures

Find phi(100). Factorise: 100 = 2^2 times 5^2. Distinct primes: 2 and 5. Step 1: 100 times (1 - 1/2) = 50. Step 2: 50 times (1 - 1/5) = 40. So phi(100) = 40. The same method for 36 gives 36 times (1 - 1/2) = 18, then 18 times (1 - 1/3) = 12. For a different number-theory check, see the Fibonacci Series Calculator and the Linear Equations in Two Variables Calculator.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *