Euler Totient Calculator
Calculate Euler totient function for any positive integer with prime factorization. Enter values for instant results with step-by-step formulas.
Reviewed by Manoj Kumar, Mathematics Educator
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.
References
Reviewed by Manoj Kumar, Mathematics Educator ยท Editorial policy