Skip to main content

Euler Totient Calculator

Calculate Euler totient function for any positive integer with prime factorization. Enter values for instant results with step-by-step formulas.

Skip to calculator
Mathematics

Euler Totient Calculator

Calculate the Euler totient function phi(n) for any positive integer. See prime factorization, coprime numbers, and understand the mathematical properties of the totient function.

Last updated: December 2025Reviewed by NovaCalculator Mathematics Team

Calculator

Adjust values & calculate
36
Euler Totient phi(36)
12
12 numbers from 1 to 36 are coprime to 36
Totient Ratio
33.33%
Prime Factors
2
Divisors
9

Computation Steps

Factorization: 36 = 2^2 x 3^2
Formula: phi(36) = 36 x (1 - 1/2) x (1 - 1/3)
Result: phi(36) = 12

Coprime Numbers (gcd = 1 with 36)

157111317192325293135

Sum of Totients over Divisors

phi(1)1
phi(2)1
phi(3)2
phi(4)2
phi(6)2
phi(9)6
phi(12)4
phi(18)6
phi(36)12
Sum36 = n
Identity: The sum of phi(d) over all divisors d of n always equals n. This is a fundamental identity in number theory that connects the totient function to divisibility.
Your Result
phi(36) = 12 | Factorization: 2^2 x 3^2 | Ratio: 33.33%
Share Your Result
Understand the Math

Formula

phi(n) = n x product(1 - 1/p) for each prime factor p of n

The totient function counts integers from 1 to n that are coprime to n. It is computed by finding the prime factorization of n and applying the product formula. For primes, phi(p) = p-1. The function is multiplicative: phi(a*b) = phi(a)*phi(b) when gcd(a,b) = 1.

Last reviewed: December 2025

Worked Examples

Example 1: Euler Totient of 36

Calculate phi(36) and find all numbers from 1 to 36 that are coprime to 36.
Solution:
Step 1: Prime factorization: 36 = 2^2 x 3^2 Step 2: Apply formula: phi(36) = 36 x (1 - 1/2) x (1 - 1/3) phi(36) = 36 x 1/2 x 2/3 = 36 x 1/3 = 12 Step 3: The 12 coprimes are: 1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35 Verification: Each of these shares no common factor with 36. Totient ratio: 12/36 = 0.3333 (33.3% of numbers are coprime)
Result: phi(36) = 12 | Factorization: 2^2 x 3^2 | Ratio: 33.3%

Example 2: Euler Totient of a Prime (97)

Calculate phi(97) and explain why the result follows directly from 97 being prime.
Solution:
Step 1: 97 is prime (no factors other than 1 and 97) Step 2: For any prime p, phi(p) = p - 1 phi(97) = 97 - 1 = 96 Step 3: All numbers from 1 to 96 are coprime to 97 Step 4: Totient ratio = 96/97 = 0.9897 (98.97%) This is the maximum possible ratio for any number of similar size.
Result: phi(97) = 96 | Prime number | Ratio: 98.97%
Expert Insights

Background & Theory

The Euler Totient Calculator applies the following established principles and formulas. Mathematics rests on a hierarchy of number systems, each extending the previous. The natural numbers (1, 2, 3, ...) support counting and ordering. The integers add negative values and zero, enabling subtraction without restriction. The rational numbers, expressible as p/q where p and q are integers and q is nonzero, close the system under division. The real numbers fill the gaps left by irrationals such as the square root of 2 or pi, forming a complete ordered field. The complex numbers, written as a + bi where i is the square root of negative one, complete the algebraic closure of the reals and allow every polynomial to have a root. Prime factorization states that every integer greater than one is uniquely expressible as a product of primes, a result known as the Fundamental Theorem of Arithmetic. Computing the greatest common divisor (GCD) of two integers relies most efficiently on the Euclidean algorithm: repeatedly replace the larger number with the remainder when it is divided by the smaller, until the remainder is zero. The last nonzero remainder is the GCD. The least common multiple (LCM) follows from the identity LCM(a, b) = |a * b| / GCD(a, b). Modular arithmetic defines equivalence classes of integers that share the same remainder under division by a modulus n. Fermat's Little Theorem and Euler's Theorem arise from this structure and underpin modern cryptography. Logarithms are the inverses of exponential functions. If b raised to the power x equals y, then the logarithm base b of y equals x. The natural logarithm uses base e, approximately 2.71828. Combinatorics counts arrangements and selections. The number of ordered arrangements (permutations) of r objects from n distinct objects is nPr = n! / (n - r)!. The number of unordered selections (combinations) is nCr = n! / (r! * (n - r)!). Pascal's triangle arranges these binomial coefficients so that each entry equals the sum of the two entries directly above it. The Fibonacci sequence, defined by F(1) = 1, F(2) = 1, and F(n) = F(n-1) + F(n-2), appears throughout nature and connects deeply to the golden ratio via Binet's formula.

History

The history behind the Euler Totient Calculator traces back through the following developments. Mathematics as a systematic discipline traces to ancient Mesopotamia. Babylonian clay tablets dating to around 1800 BCE demonstrate knowledge of quadratic equations, Pythagorean triples, and base-60 arithmetic, suggesting a practical mathematical tradition far preceding Greek formalism. Euclid of Alexandria compiled the Elements around 300 BCE, establishing the axiomatic method that would define rigorous mathematics for over two thousand years. His work organized plane geometry, number theory, and proportion into logically chained propositions derived from a small set of postulates. The algorithm bearing his name for computing GCDs appears in Book VII and remains in use today. In the 9th century, the Persian scholar Muhammad ibn Musa Al-Khwarizmi wrote Al-Kitab al-mukhtasar fi hisab al-jabr wal-muqabala, the treatise whose title gave algebra its name. He systematized the solution of linear and quadratic equations and described procedures that operated on unknowns as objects, a conceptual leap away from purely numerical calculation. Rene Descartes introduced coordinate geometry in 1637 by uniting algebra and Euclidean geometry, allowing curves to be studied through equations. This synthesis set the stage for calculus. Isaac Newton and Gottfried Wilhelm Leibniz independently developed calculus during the 1660s and 1670s, triggering a priority dispute that lasted decades and divided British and Continental mathematicians. Carl Friedrich Gauss proved the Fundamental Theorem of Algebra in 1799, showing that every nonconstant polynomial has at least one complex root. His Disquisitiones Arithmeticae of 1801 established modern number theory. David Hilbert's formalist program at the turn of the 20th century sought to place all of mathematics on an explicit axiomatic foundation, a project that Kurt Godel's incompleteness theorems of 1931 showed to be fundamentally limited. Alan Turing's work in the 1930s on computability introduced the theoretical model of the stored-program computer and linked mathematical logic directly to the limits of algorithmic calculation. His proof that no algorithm can decide in general whether an arbitrary program will halt or run forever placed fundamental boundaries on what mathematics can mechanically determine, and it opened the discipline now known as theoretical computer science.

Share this calculator

Explore More

Frequently Asked Questions

The Euler totient function, denoted phi(n) or sometimes written as the Greek letter phi, counts the number of positive integers from 1 to n that are coprime to n, meaning they share no common factor other than 1 with n. For example, phi(12) = 4 because the numbers 1, 5, 7, and 11 are the only numbers from 1 to 12 that share no common factor with 12. The function was introduced by Leonhard Euler in 1763 and is one of the most important functions in number theory. It appears in modular arithmetic, group theory, and is fundamental to the RSA cryptographic algorithm. For any prime p, phi(p) = p-1 since all numbers from 1 to p-1 are coprime to a prime number.
The most efficient method for computing phi(n) uses the prime factorization of n and the product formula: phi(n) = n times the product of (1 - 1/p) for each distinct prime factor p of n. For example, to compute phi(36): first factorize 36 = 2^2 x 3^2. Then phi(36) = 36 x (1 - 1/2) x (1 - 1/3) = 36 x 1/2 x 2/3 = 12. This formula works because it systematically removes all multiples of each prime factor using the inclusion-exclusion principle. The beauty of this formula is that only the distinct prime factors matter, not their exponents, making computation efficient even for large numbers. This is why finding the prime factorization is the key computational step.
The RSA cryptographic algorithm relies directly on the Euler totient function for key generation. In RSA, two large primes p and q are chosen, and their product n = p x q forms the modulus. The totient phi(n) = (p-1)(q-1) is computed, and a public exponent e coprime to phi(n) is selected. The private key d is the modular multiplicative inverse of e modulo phi(n), meaning e x d mod phi(n) = 1. Euler theorem guarantees that m^(e*d) mod n = m for any message m coprime to n, enabling encryption and decryption. The security of RSA depends on the difficulty of computing phi(n) without knowing the factorization of n. If an attacker could compute phi(n), they could easily derive the private key.
Euler theorem states that if a and n are coprime positive integers, then a^phi(n) mod n = 1. This is a generalization of Fermat Little Theorem, which is the special case where n is prime. For example, since phi(10) = 4, we know that 3^4 mod 10 = 81 mod 10 = 1, and indeed 7^4 mod 10 = 2401 mod 10 = 1. This theorem is the mathematical foundation of modular exponentiation in cryptography. It tells us that modular powers are periodic with period dividing phi(n), allowing us to reduce large exponents modulo phi(n) before computing. The theorem also implies that a^(-1) mod n = a^(phi(n)-1) mod n, providing a method for computing modular inverses.
The Euler totient function has several elegant mathematical properties. It is multiplicative: phi(a x b) = phi(a) x phi(b) when gcd(a, b) = 1. For any prime p, phi(p) = p - 1. For prime powers, phi(p^k) = p^k - p^(k-1) = p^(k-1) x (p-1). The sum of phi(d) over all divisors d of n equals n itself, a beautiful identity used in Mobius inversion. For n greater than 2, phi(n) is always even because if gcd(a, n) = 1, then gcd(n-a, n) = 1, so coprimes come in pairs summing to n. The average value of phi(n)/n approaches 6/pi^2 as n grows large. These properties make the totient function a cornerstone of algebraic number theory and have applications across pure and applied mathematics.
In group theory, the Euler totient function gives the order of the multiplicative group of integers modulo n, written as (Z/nZ)*, which consists of all integers from 1 to n-1 that are coprime to n under multiplication modulo n. This group has exactly phi(n) elements. When n is prime, this group is cyclic and isomorphic to Z/(n-1)Z, with every non-zero element being a unit. For composite n, the Chinese Remainder Theorem decomposes (Z/nZ)* into a direct product of groups corresponding to the prime power factors of n. The generators of this cyclic group when it is cyclic are called primitive roots modulo n, and there are exactly phi(phi(n)) of them. This connection between the totient function and group structure is central to abstract algebra.
Educational Note: This calculator is provided for educational and informational purposes. Results are based on the formulas and inputs provided. Always verify important calculations independently. NovaCalculator processes calculator inputs client-side; optional analytics follow visitor consent settings.Reviewed by: NovaCalculator Mathematics Team โ€” Verified against standard mathematical and scientific references. Last reviewed: December 2025. ยฉ 2024โ€“2026 NovaCalculator.

Share this calculator

Formula

phi(n) = n x product(1 - 1/p) for each prime factor p of n

The totient function counts integers from 1 to n that are coprime to n. It is computed by finding the prime factorization of n and applying the product formula. For primes, phi(p) = p-1. The function is multiplicative: phi(a*b) = phi(a)*phi(b) when gcd(a,b) = 1.

Worked Examples

Example 1: Euler Totient of 36

Problem: Calculate phi(36) and find all numbers from 1 to 36 that are coprime to 36.

Solution: Step 1: Prime factorization: 36 = 2^2 x 3^2\nStep 2: Apply formula: phi(36) = 36 x (1 - 1/2) x (1 - 1/3)\nphi(36) = 36 x 1/2 x 2/3 = 36 x 1/3 = 12\nStep 3: The 12 coprimes are: 1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35\nVerification: Each of these shares no common factor with 36.\nTotient ratio: 12/36 = 0.3333 (33.3% of numbers are coprime)

Result: phi(36) = 12 | Factorization: 2^2 x 3^2 | Ratio: 33.3%

Example 2: Euler Totient of a Prime (97)

Problem: Calculate phi(97) and explain why the result follows directly from 97 being prime.

Solution: Step 1: 97 is prime (no factors other than 1 and 97)\nStep 2: For any prime p, phi(p) = p - 1\nphi(97) = 97 - 1 = 96\nStep 3: All numbers from 1 to 96 are coprime to 97\nStep 4: Totient ratio = 96/97 = 0.9897 (98.97%)\nThis is the maximum possible ratio for any number of similar size.

Result: phi(97) = 96 | Prime number | Ratio: 98.97%

Frequently Asked Questions

What is the Euler totient function and what does it calculate?

The Euler totient function, denoted phi(n) or sometimes written as the Greek letter phi, counts the number of positive integers from 1 to n that are coprime to n, meaning they share no common factor other than 1 with n. For example, phi(12) = 4 because the numbers 1, 5, 7, and 11 are the only numbers from 1 to 12 that share no common factor with 12. The function was introduced by Leonhard Euler in 1763 and is one of the most important functions in number theory. It appears in modular arithmetic, group theory, and is fundamental to the RSA cryptographic algorithm. For any prime p, phi(p) = p-1 since all numbers from 1 to p-1 are coprime to a prime number.

How is the Euler totient function calculated using prime factorization?

The most efficient method for computing phi(n) uses the prime factorization of n and the product formula: phi(n) = n times the product of (1 - 1/p) for each distinct prime factor p of n. For example, to compute phi(36): first factorize 36 = 2^2 x 3^2. Then phi(36) = 36 x (1 - 1/2) x (1 - 1/3) = 36 x 1/2 x 2/3 = 12. This formula works because it systematically removes all multiples of each prime factor using the inclusion-exclusion principle. The beauty of this formula is that only the distinct prime factors matter, not their exponents, making computation efficient even for large numbers. This is why finding the prime factorization is the key computational step.

What is the relationship between the Euler totient function and RSA encryption?

The RSA cryptographic algorithm relies directly on the Euler totient function for key generation. In RSA, two large primes p and q are chosen, and their product n = p x q forms the modulus. The totient phi(n) = (p-1)(q-1) is computed, and a public exponent e coprime to phi(n) is selected. The private key d is the modular multiplicative inverse of e modulo phi(n), meaning e x d mod phi(n) = 1. Euler theorem guarantees that m^(e*d) mod n = m for any message m coprime to n, enabling encryption and decryption. The security of RSA depends on the difficulty of computing phi(n) without knowing the factorization of n. If an attacker could compute phi(n), they could easily derive the private key.

What is Euler theorem and how does it relate to the totient function?

Euler theorem states that if a and n are coprime positive integers, then a^phi(n) mod n = 1. This is a generalization of Fermat Little Theorem, which is the special case where n is prime. For example, since phi(10) = 4, we know that 3^4 mod 10 = 81 mod 10 = 1, and indeed 7^4 mod 10 = 2401 mod 10 = 1. This theorem is the mathematical foundation of modular exponentiation in cryptography. It tells us that modular powers are periodic with period dividing phi(n), allowing us to reduce large exponents modulo phi(n) before computing. The theorem also implies that a^(-1) mod n = a^(phi(n)-1) mod n, providing a method for computing modular inverses.

What are the key properties and identities of the Euler totient function?

The Euler totient function has several elegant mathematical properties. It is multiplicative: phi(a x b) = phi(a) x phi(b) when gcd(a, b) = 1. For any prime p, phi(p) = p - 1. For prime powers, phi(p^k) = p^k - p^(k-1) = p^(k-1) x (p-1). The sum of phi(d) over all divisors d of n equals n itself, a beautiful identity used in Mobius inversion. For n greater than 2, phi(n) is always even because if gcd(a, n) = 1, then gcd(n-a, n) = 1, so coprimes come in pairs summing to n. The average value of phi(n)/n approaches 6/pi^2 as n grows large. These properties make the totient function a cornerstone of algebraic number theory and have applications across pure and applied mathematics.

What is the connection between the totient function and group theory?

In group theory, the Euler totient function gives the order of the multiplicative group of integers modulo n, written as (Z/nZ)*, which consists of all integers from 1 to n-1 that are coprime to n under multiplication modulo n. This group has exactly phi(n) elements. When n is prime, this group is cyclic and isomorphic to Z/(n-1)Z, with every non-zero element being a unit. For composite n, the Chinese Remainder Theorem decomposes (Z/nZ)* into a direct product of groups corresponding to the prime power factors of n. The generators of this cyclic group when it is cyclic are called primitive roots modulo n, and there are exactly phi(phi(n)) of them. This connection between the totient function and group structure is central to abstract algebra.

References

Reviewed by Manoj Kumar, Mathematics Educator ยท Editorial policy