Euler's Totient Function Calculator
Calculate Euler's totient function φ(n) with step-by-step prime factorization, interactive coprime number grid, and detailed analysis. Essential for RSA cryptography, modular arithmetic, and number theory.
Your ad blocker is preventing us from showing ads
MiniWebtool is free because of ads. If this tool helped you, please support us by going Premium (ad‑free + faster tools), or allowlist MiniWebtool.com and reload.
- Allow ads for MiniWebtool.com, then reload
- Or upgrade to Premium (ad‑free)
About Euler's Totient Function Calculator
Welcome to the Euler's Totient Function Calculator, a comprehensive number theory tool that computes φ(n) (Euler's phi function) with step-by-step prime factorization, interactive coprime number grid visualization, and in-depth analysis. Whether you are studying abstract algebra, preparing for math competitions, working on RSA cryptography, or exploring modular arithmetic, this calculator delivers professional-grade computation with rich educational content.
What is Euler's Totient Function?
Euler's totient function φ(n), also known as Euler's phi function, counts the number of positive integers from 1 to n that are relatively prime (coprime) to n. Two numbers are coprime when their greatest common divisor (GCD) equals 1.
For example, φ(12) = 4 because exactly four numbers — 1, 5, 7, and 11 — are coprime to 12 among the integers from 1 to 12.
The Product Formula
The most efficient way to compute φ(n) uses the prime factorization of n. If \(n = p_1^{a_1} \cdot p_2^{a_2} \cdots p_k^{a_k}\), then:
This means we multiply n by \((1 - 1/p)\) for each distinct prime factor p of n. The exponents do not matter — only the distinct primes.
Key Properties
Euler's Theorem
Euler's theorem is the key result that makes the totient function crucial in cryptography:
This generalizes Fermat's little theorem (which is the special case when n is prime). It forms the mathematical foundation of RSA encryption.
How to Use This Calculator
- Enter a positive integer: Type any value from 1 to 1,000,000 in the input field.
- Use quick examples: Click the example buttons to try classic values like primes, composite numbers, or RSA-style semiprimes.
- View your results: The calculator shows φ(n), prime factorization, coprime ratio, and detected properties.
- Explore the coprime grid: For n ≤ 400, see which numbers are coprime to n in an animated visual grid.
- Study the trend chart: See how φ(k) varies for k = 1 to min(n, 100).
RSA Encryption Connection
In RSA cryptography, Euler's totient function plays a central role:
- Choose two large primes p and q. Compute n = p × q.
- Compute φ(n) = (p−1)(q−1).
- Choose public exponent e with gcd(e, φ(n)) = 1.
- Compute private exponent d such that e × d ≡ 1 (mod φ(n)).
The security of RSA relies on the difficulty of computing φ(n) without knowing the factorization of n. If an attacker could efficiently compute φ(n), they could break RSA.
Common Values of φ(n)
| n | φ(n) | Coprime integers | Notes |
|---|---|---|---|
| 1 | 1 | {1} | By definition |
| 2 | 1 | {1} | Prime |
| 6 | 2 | {1, 5} | 2 × 3 |
| 10 | 4 | {1, 3, 7, 9} | 2 × 5 |
| 12 | 4 | {1, 5, 7, 11} | 2² × 3 |
| 15 | 8 | {1, 2, 4, 7, 8, 11, 13, 14} | 3 × 5 |
| 30 | 8 | {1, 7, 11, 13, 17, 19, 23, 29} | 2 × 3 × 5 |
| 100 | 40 | — | 2² × 5² |
Frequently Asked Questions
What is Euler's totient function?
Euler's totient function φ(n), also called Euler's phi function, counts the number of positive integers from 1 to n that are relatively prime (coprime) to n. Two numbers are coprime when their greatest common divisor (GCD) is 1. For example, φ(12) = 4 because only 1, 5, 7, and 11 are coprime to 12.
How do you calculate Euler's totient function?
To calculate φ(n): (1) Find the prime factorization of n. (2) Apply the product formula: φ(n) = n × ∏(1 − 1/p) for each distinct prime factor p of n. For example, φ(12) = 12 × (1−1/2) × (1−1/3) = 12 × 1/2 × 2/3 = 4. For a prime p, φ(p) = p−1. For a prime power p^k, φ(p^k) = p^k − p^(k−1).
Why is Euler's totient function important in RSA encryption?
In RSA encryption, the modulus n = p × q is the product of two large primes. The totient φ(n) = (p−1)(q−1) is used to compute the private key: the decryption exponent d must satisfy e × d ≡ 1 (mod φ(n)), where e is the public encryption exponent. Without knowing φ(n) — which requires factoring n — computing d is computationally infeasible.
What is Euler's theorem and how does it relate to the totient function?
Euler's theorem states that if a and n are coprime, then a^φ(n) ≡ 1 (mod n). This is a generalization of Fermat's little theorem (which applies when n is prime). It is fundamental in modular arithmetic and cryptography, providing the mathematical basis for RSA encryption and efficient modular exponentiation.
What are the key properties of Euler's totient function?
Key properties include: (1) φ(1) = 1. (2) For prime p: φ(p) = p−1. (3) For prime power p^k: φ(p^k) = p^(k−1)(p−1). (4) Multiplicative property: if gcd(m,n) = 1, then φ(m×n) = φ(m)×φ(n). (5) Sum over divisors: Σ φ(d) = n for all divisors d of n. (6) φ(n) is always even for n > 2.
What does it mean for two numbers to be coprime?
Two integers a and b are coprime (also called relatively prime) if their greatest common divisor is 1, meaning they share no common prime factors. For example, 8 and 15 are coprime because gcd(8,15) = 1, even though neither is prime. The totient function φ(n) counts exactly how many integers from 1 to n are coprime to n.
Additional Resources
Reference this content, page, or tool as:
"Euler's Totient Function Calculator" at https://MiniWebtool.com// from MiniWebtool, https://MiniWebtool.com/
by miniwebtool team. Updated: Feb 17, 2026
You can also try our AI Math Solver GPT to solve your math problems through natural language question and answer.