Euler's Totient Function (φ) Calculator — Coprime Counter

Enter an integer N (1 to 1,000,000) to instantly find the number of integers from 1 to N that are coprime to N (Euler's totient function φ(N)), shown with the full prime factorization and formula, not just the answer. Includes a free φ(n) reference table for 1-100.

φ(n) reference table for 1-100

A reference table showing the prime factorization and Euler totient value for every integer from 1 to 100.

N Factorization φ(n)
1 1 1
2 2 1
3 3 2
4 2² 2
5 5 4
6 2 × 3 2
7 7 6
8 2³ 4
9 3² 6
10 2 × 5 4
11 11 10
12 2² × 3 4
13 13 12
14 2 × 7 6
15 3 × 5 8
16 2⁴ 8
17 17 16
18 2 × 3² 6
19 19 18
20 2² × 5 8
21 3 × 7 12
22 2 × 11 10
23 23 22
24 2³ × 3 8
25 5² 20
26 2 × 13 12
27 3³ 18
28 2² × 7 12
29 29 28
30 2 × 3 × 5 8
31 31 30
32 2⁵ 16
33 3 × 11 20
34 2 × 17 16
35 5 × 7 24
36 2² × 3² 12
37 37 36
38 2 × 19 18
39 3 × 13 24
40 2³ × 5 16
41 41 40
42 2 × 3 × 7 12
43 43 42
44 2² × 11 20
45 3² × 5 24
46 2 × 23 22
47 47 46
48 2⁴ × 3 16
49 7² 42
50 2 × 5² 20
51 3 × 17 32
52 2² × 13 24
53 53 52
54 2 × 3³ 18
55 5 × 11 40
56 2³ × 7 24
57 3 × 19 36
58 2 × 29 28
59 59 58
60 2² × 3 × 5 16
61 61 60
62 2 × 31 30
63 3² × 7 36
64 2⁶ 32
65 5 × 13 48
66 2 × 3 × 11 20
67 67 66
68 2² × 17 32
69 3 × 23 44
70 2 × 5 × 7 24
71 71 70
72 2³ × 3² 24
73 73 72
74 2 × 37 36
75 3 × 5² 40
76 2² × 19 36
77 7 × 11 60
78 2 × 3 × 13 24
79 79 78
80 2⁴ × 5 32
81 3⁴ 54
82 2 × 41 40
83 83 82
84 2² × 3 × 7 24
85 5 × 17 64
86 2 × 43 42
87 3 × 29 56
88 2³ × 11 40
89 89 88
90 2 × 3² × 5 24
91 7 × 13 72
92 2² × 23 44
93 3 × 31 60
94 2 × 47 46
95 5 × 19 72
96 2⁵ × 3 32
97 97 96
98 2 × 7² 42
99 3² × 11 60
100 2² × 5² 40

What Euler’s totient function is

Euler’s totient function φ(n) counts how many of the integers from 1 to n are coprime to n. Coprime means their greatest common divisor is 1 — that they share no prime factor. For instance φ(9) is 6, because 1, 2, 4, 5, 7 and 8 are the numbers sharing no prime factor with 9.

This tool works out φ(N) from the integer you enter and shows, besides the answer, **the prime factorisation of N and the formula that leads from it to φ(N)**. The formula is φ(n) = n × Π(1 − 1/p), the product taken over the distinct prime factors p of n. However many times a prime is repeated, it enters the product only once: the exponent makes no difference to the result. Anything from 1 to 1,000,000 is accepted, and a table of φ(n) for 1 to 100 is set out below.

How to use the totient calculator

  1. Enter the integer N Give a whole number from 1 to 1,000,000. Anything outside that range, or not a whole number, raises an error.
  2. Read the value of φ(N) As you type, the count of integers from 1 to N that are coprime to N appears.
  3. Check the prime factorisation You are shown which primes N breaks into — a thread to follow if you want to see where the value of φ(N) comes from.
  4. Trace the derivation through the formula The formula φ(n) = n × Π(1 − 1/p) is displayed with the actual prime factors filled in, ready to check a calculation done by hand.
  5. Compare against the table A list of φ(n) for 1 to 100 sits below, so you can see regularities with your own eyes — that φ of a prime is one less than the prime, for one.

Tips for getting more out of it

  • Euler's totient function φ(n) counts the integers from 1 to n that are coprime to n. For example, φ(9) = 6 (1, 2, 4, 5, 7, and 8 are coprime to 9).
  • When n is a prime p, φ(p) = p − 1, because every number from 1 to p except p itself is coprime to a prime.
  • When n is the product of two distinct primes p and q, φ(pq) = (p−1)(q−1) — a property used directly in RSA key generation.
  • The formula φ(n) = n × Π(1 − 1/p) is a product over the distinct prime factors p of n; the exponent of each prime does not affect the result.
  • This tool supports the range 1 to 1,000,000 and computes φ(n) instantly using trial-division factorization.

Where Euler’s totient function helps

Studying number theory and marking homework

Confirm whether the φ(n) you worked out by hand is right. Since the factorisation and the formula are shown alongside, you can catch a mistake in the derivation and not only in the answer.

Understanding how RSA works

RSA uses the product n = pq of two primes as part of the public key, and building the private key needs φ(n) = (p−1)(q−1). Working it through with small primes makes that relation concrete.

Checking Euler’s theorem

Euler’s theorem says that for a coprime to n, a raised to the power φ(n) leaves a remainder of 1 on division by n. Get φ(n) first and you can try the theorem out on small numbers.

Observing the multiplicative property

When m and n are coprime, φ(mn) = φ(m)φ(n). Combining values from the table lets you see that this really holds.

When it is the factorisation you want

If you need only the factors, use prime factorisation; to test whether a number is prime, the primality checker.

Terms used with the totient function

Euler’s totient function
The function returning how many integers from 1 to n are coprime to n. Written φ(n), it was introduced by Leonhard Euler in the eighteenth century.
Coprime
The state of two integers whose greatest common divisor is 1 — which comes to the same thing as sharing no prime factor at all.
Prime factorisation
Writing an integer as a product of primes. Since φ(n) is settled by the distinct prime factors of n alone, this factorisation is where the calculation starts.
Multiplicative function
A function for which f(mn) = f(m)f(n) whenever m and n are coprime. φ has this property, which is why the totient of a large number can be assembled from its prime factors.
Euler’s theorem
The theorem that for any a coprime to n, a to the power φ(n) always leaves a remainder of 1 on division by n. Restricted to a prime modulus, it is Fermat’s little theorem.
RSA
A public-key cipher that uses the product of two large primes as its public key. The private key needs φ(n), and the fact that φ(n) cannot be had without factorising n is one of the grounds of its security.

Frequently Asked Questions

Beyond its role in foundational number theory, it is central to cryptography, especially RSA key generation. The RSA private key is derived using φ(n) = (p−1)(q−1).

By convention, φ(1) = 1. Although 1 is the only integer up to 1 that could be considered, defining φ(1) = 1 keeps the function's multiplicative properties consistent, which is the standard mathematical convention.

Yes. Since a prime p has no divisors other than 1 and itself, every integer from 1 to p except p is coprime to it, so φ(p) = p − 1.

RSA uses a composite number n = pq, the product of two large primes, as part of the public key. Computing the private key requires φ(n) = (p−1)(q−1), but φ(n) cannot be found without factoring n — this difficulty of factoring large numbers is the foundation of RSA's security.
Tool-kun

Side Note — The 18th-century function that counts what's coprime

Euler's totient function was introduced around 1763 by the Swiss mathematician Leonhard Euler, originally while generalizing Fermat's little theorem to composite numbers. The now-standard symbol φ (phi) was adopted later by other mathematicians who systematized the notation.

Counting coprime numbers may sound like a simple exercise, but φ(n) has several elegant properties. For instance, summing φ(d) over every divisor d of n always equals n itself (Σφ(d) = n) — one of the fundamental identities in elementary number theory.

Today, φ(n) plays an essential role in RSA cryptography. RSA uses the product of two large primes n = pq as part of the public key, and computing the private key requires φ(n) = (p−1)(q−1). The fact that φ(n) cannot be computed without factoring n (at least with currently known algorithms) is one of the pillars underlying RSA's security.