Free Euler Totient (φ(n)) Calculator with Steps & Number Theory Tools

Compute φ(n), Carmichael's λ(n), verify Euler's theorem, and find primitive roots with detailed explanations.

Euler's Totient Calculator

Enter numbers to compute φ(n), λ(n), and related functions

Totient Results

TXT
CSV
JSON
Print
-
φ(n)
-
λ(n)
-
Prime Factors
-
Coprime Count

Recent Calculations

What is Euler's Totient Function?

Euler's totient function (denoted φ(n) or phi(n)) counts the positive integers up to a given integer n that are relatively prime to n (i.e., numbers less than n that share no common factors with n except 1).

Key Concepts:

  • Relatively Prime: Two numbers are relatively prime if their greatest common divisor (GCD) is 1
  • φ(1) = 1: By definition, 1 is relatively prime to itself
  • Multiplicative Function: φ(ab) = φ(a)φ(b) if a and b are coprime
  • Prime Numbers: For prime p, φ(p) = p - 1

Basic Calculation

φ(n) = n × ∏(1 - 1/p) where p runs over distinct prime factors of n.

φ(12) = 12 × (1-1/2) × (1-1/3)
= 12 × 1/2 × 2/3 = 4
Numbers: 1,5,7,11

Importance in Mathematics

Fundamental in number theory, used in Euler's theorem, RSA encryption, and primitive root calculations.

Euler's Theorem:
a^φ(n) ≡ 1 (mod n)
if gcd(a,n)=1

Computational Methods

Multiple algorithms: prime factorization, sieve method, multiplicative property, and recursive formulas.

φ(100) = φ(4)×φ(25)
= 2 × 20 = 40
Since 4 and 25 are coprime

Formulas & Properties of φ(n)

Euler's totient function has several important formulas and properties:

Prime Numbers

For prime p: φ(p) = p - 1

φ(7) = 7 - 1 = 6
Numbers: 1,2,3,4,5,6

Prime Powers

For prime power p^k: φ(p^k) = p^k - p^(k-1)

φ(8) = φ(2^3)
= 8 - 4 = 4
Numbers: 1,3,5,7

Multiplicative Property

If gcd(m,n)=1, then φ(mn) = φ(m)φ(n)

φ(15) = φ(3)×φ(5)
= 2 × 4 = 8
Since 3 and 5 are coprime

General Formula

φ(n) = n × ∏(1 - 1/p) for distinct primes p dividing n

φ(30) = 30×(1-1/2)×(1-1/3)×(1-1/5)
= 30×1/2×2/3×4/5 = 8

Summation Formula

∑ φ(d) = n, where d runs over all divisors of n

For n=12:
φ(1)+φ(2)+φ(3)+φ(4)+φ(6)+φ(12)
= 1+1+2+2+2+4 = 12

Product Formula

φ(n) = n × ∏(p-1)/p for distinct primes p dividing n

φ(18) = 18 × (2-1)/2 × (3-1)/3
= 18 × 1/2 × 2/3 = 6
φ(n) = n × ∏(1 - 1/p) for p|n, p prime

Carmichael Function λ(n)

The Carmichael function λ(n) is the smallest positive integer m such that a^m ≡ 1 (mod n) for all integers a coprime to n.

Definition

λ(n) = smallest m such that a^m ≡ 1 (mod n) for all gcd(a,n)=1

λ(8) = 2
For all a coprime to 8:
a^2 ≡ 1 (mod 8)

Prime Powers

For odd prime p: λ(p^k) = φ(p^k) = p^(k-1)(p-1)

λ(9) = φ(9) = 6
For p=2: λ(2)=1, λ(4)=2,
λ(2^k)=2^(k-2) for k≥3

Relation to φ(n)

λ(n) divides φ(n) for all n, and λ(n) = φ(n) for n=1,2,4,p^k,2p^k

For n=15:
φ(15)=8, λ(15)=4
4 divides 8

Multiplicative Property

λ(lcm(m,n)) = lcm(λ(m), λ(n)) for coprime m,n

λ(15) = lcm(λ(3),λ(5))
= lcm(2,4) = 4

Applications

Used in RSA cryptography, primality testing, and modular exponentiation optimization

In RSA: λ(n) used instead of φ(n)
for private key calculation

Special Values

λ(1)=1, λ(2)=1, λ(4)=2, λ(2^k)=2^(k-2) for k≥3

λ(8)=2, λ(16)=4, λ(32)=8
Pattern: λ(2^k)=2^(k-2)

Euler's Theorem

Euler's theorem is a fundamental result in number theory that generalizes Fermat's little theorem.

Euler's Theorem: If a and n are coprime positive integers (gcd(a,n)=1), then a^φ(n) ≡ 1 (mod n).

Statement

For gcd(a,n)=1: a^φ(n) ≡ 1 (mod n)

For a=3, n=10:
φ(10)=4, gcd(3,10)=1
3^4=81≡1 (mod 10)

Fermat's Little Theorem

Special case when n is prime: a^(p-1) ≡ 1 (mod p)

For prime p=7:
φ(7)=6
a^6 ≡ 1 (mod 7)
for gcd(a,7)=1

Applications

Modular exponent simplification, RSA encryption, primality testing

7^100 mod 10:
φ(10)=4, 100 mod 4=0
7^100≡7^0≡1 (mod 10)

Generalization

Carmichael's theorem: a^λ(n) ≡ 1 (mod n) for gcd(a,n)=1

For n=15, λ(15)=4
a^4 ≡ 1 (mod 15)
for all gcd(a,15)=1

Proof Sketch

Based on group theory: units modulo n form a group of order φ(n)

Units modulo n:
{a mod n: gcd(a,n)=1}
Group order = φ(n)

Computational Use

Reduce large exponents modulo n using φ(n)

5^123 mod 12:
φ(12)=4, 123 mod 4=3
5^123≡5^3≡125≡5 (mod 12)

Primitive Roots

A primitive root modulo n is a number g such that every number coprime to n is congruent to a power of g modulo n.

Primitive Root: g is a primitive root modulo n if the multiplicative order of g modulo n is φ(n).

Definition

g is primitive root mod n if {g^k mod n: k=1..φ(n)} generates all units mod n

For n=7, φ(7)=6
3 is primitive root:
3^1=3, 3^2=2, 3^3=6,
3^4=4, 3^5=5, 3^6=1

Existence Theorem

Primitive roots exist only for n=1,2,4,p^k,2p^k where p is odd prime

Exist: 7, 9, 10, 14
Not exist: 8, 12, 15, 16

Number of Roots

If primitive roots exist, there are φ(φ(n)) of them

For n=7, φ(7)=6
φ(φ(7))=φ(6)=2
Primitive roots: 3 and 5

Finding Roots

Test numbers g where gcd(g,n)=1 and check if order(g)=φ(n)

For n=14, φ(14)=6
3 is primitive root:
3^6≡1 mod 14,
3^k≠1 for k<6

Applications

Discrete logarithm, Diffie-Hellman key exchange, number theory proofs

Diffie-Hellman:
Use primitive root g mod p
for secure key exchange

Properties

If g is primitive root, then g^k is primitive root iff gcd(k,φ(n))=1

For n=7, g=3:
3^1=3, 3^5=5 are roots
since gcd(1,6)=1, gcd(5,6)=1

Real-World Applications of Totient Function

Euler's totient function has numerous practical applications in cryptography, computer science, and mathematics:

RSA Cryptography

  • φ(n) used in key generation
  • Private key calculation
  • Message encryption/decryption
  • Digital signatures

Computer Science

  • Modular exponent optimization
  • Algorithm complexity analysis
  • Hash function design
  • Random number generation

Mathematics Research

  • Number theory proofs
  • Analytic number theory
  • Distribution of primes
  • Diophantine equations

Engineering

  • Signal processing
  • Error correction codes
  • Cryptographic protocols
  • Secure communications

Education

  • Number theory courses
  • Cryptography education
  • Mathematical competitions
  • Research projects

Finance & Security

  • Banking security systems
  • Secure transactions
  • Blockchain technology
  • Digital certificates

Solved Totient Examples

Step-by-step solutions to common totient function problems:

Example 1: φ(100)
Calculate Euler's totient function for 100.
1. Prime factorization: 100 = 2² × 5²
2. Formula: φ(100) = 100 × (1-1/2) × (1-1/5)
3. Calculation: 100 × 1/2 × 4/5 = 40
4. Verify: There are 40 numbers <100 coprime to 100
Result: φ(100) = 40
Example 2: φ(φ(100))
Calculate φ(φ(100)) = φ(40).
1. From Example 1: φ(100) = 40
2. Prime factorization: 40 = 2³ × 5
3. Formula: φ(40) = 40 × (1-1/2) × (1-1/5)
4. Calculation: 40 × 1/2 × 4/5 = 16
Result: φ(φ(100)) = 16
Example 3: Verify Euler's Theorem for 7³ mod 10
Verify that 7^φ(10) ≡ 1 (mod 10).
1. Calculate φ(10): φ(10) = 10 × (1-1/2) × (1-1/5) = 4
2. Compute 7⁴ = 2401
3. 2401 mod 10 = 1
4. Verification: 7⁴ ≡ 1 (mod 10) ✓
Result: Euler's theorem verified
Example 4: Find primitive roots modulo 7
Find all primitive roots modulo 7.
1. φ(7) = 6
2. Test numbers 1-6 coprime to 7
3. Check orders: order(3)=6, order(5)=6
4. Number of roots: φ(φ(7)) = φ(6) = 2
Result: Primitive roots: 3 and 5
Example 5: Carmichael function λ(60)
Calculate Carmichael's function λ(60).
1. Prime factorization: 60 = 2² × 3 × 5
2. λ(4)=2, λ(3)=2, λ(5)=4
3. λ(60) = lcm(λ(4), λ(3), λ(5))
4. Calculation: lcm(2,2,4) = 4
Result: λ(60) = 4
Example 6: Multiplicative property
Verify φ(35) = φ(5) × φ(7).
1. φ(5) = 4 (since 5 is prime)
2. φ(7) = 6 (since 7 is prime)
3. φ(5) × φ(7) = 4 × 6 = 24
4. φ(35) = 35 × (1-1/5) × (1-1/7) = 35 × 4/5 × 6/7 = 24
Result: Multiplicative property verified

Practice Problems

Test your understanding with these totient function problems:

Problem 1: Calculate φ(72). Show your work using prime factorization.

Solution:

1. Prime factorization: 72 = 2³ × 3²

2. Formula: φ(72) = 72 × (1-1/2) × (1-1/3)

3. Calculation: 72 × 1/2 × 2/3 = 24

4. Alternative: φ(72) = φ(8)×φ(9) = 4 × 6 = 24

Therefore, φ(72) = 24.

Problem 2: Find all numbers n such that φ(n) = 12.

Solution:

We need to solve φ(n) = 12.

Possible n values:

1. n = 13 (prime): φ(13) = 12

2. n = 21: φ(21) = φ(3)×φ(7) = 2×6 = 12

3. n = 26: φ(26) = φ(2)×φ(13) = 1×12 = 12

4. n = 28: φ(28) = φ(4)×φ(7) = 2×6 = 12

5. n = 36: φ(36) = φ(4)×φ(9) = 2×6 = 12

6. n = 42: φ(42) = φ(2)×φ(3)×φ(7) = 1×2×6 = 12

Therefore, n = 13, 21, 26, 28, 36, 42.

Problem 3: Verify Euler's theorem for a=2, n=15.

Solution:

1. Check gcd(2,15) = 1 ✓ (coprime)

2. Calculate φ(15) = φ(3)×φ(5) = 2×4 = 8

3. Compute 2^8 = 256

4. 256 mod 15 = 1 (since 255 = 15×17)

5. Verification: 2^8 ≡ 1 (mod 15) ✓

Therefore, Euler's theorem is verified.

Problem 4: Calculate λ(30) (Carmichael function).

Solution:

1. Prime factorization: 30 = 2 × 3 × 5

2. λ(2) = 1, λ(3) = 2, λ(5) = 4

3. λ(30) = lcm(λ(2), λ(3), λ(5))

4. lcm(1, 2, 4) = 4

5. Verify: For all a coprime to 30, a^4 ≡ 1 (mod 30)

Therefore, λ(30) = 4.

Problem 5: Find φ(φ(φ(1000))).

Solution:

1. φ(1000) = φ(2³×5³) = 1000 × (1-1/2) × (1-1/5) = 1000 × 1/2 × 4/5 = 400

2. φ(400) = φ(2⁴×5²) = 400 × (1-1/2) × (1-1/5) = 400 × 1/2 × 4/5 = 160

3. φ(160) = φ(2⁵×5) = 160 × (1-1/2) × (1-1/5) = 160 × 1/2 × 4/5 = 64

Therefore, φ(φ(φ(1000))) = 64.

How to Calculate φ(n) Step-by-Step

Follow this systematic approach to calculate Euler's totient function:

1

Prime Factorization

Find the prime factorization of n: n = p₁^k₁ × p₂^k₂ × ... × pᵣ^kᵣ

n = 60
60 = 2² × 3 × 5
2

Apply Formula

Use the formula: φ(n) = n × ∏(1 - 1/pᵢ) for distinct primes pᵢ

φ(60) = 60 × (1-1/2) × (1-1/3) × (1-1/5)
3

Simplify

Simplify the product: (1 - 1/p) = (p-1)/p

φ(60) = 60 × 1/2 × 2/3 × 4/5
4

Calculate

Multiply all terms together

60 × 1/2 = 30
30 × 2/3 = 20
20 × 4/5 = 16
∴ φ(60) = 16
5

Verify

Check using alternative method or known properties

φ(60) = φ(4)×φ(3)×φ(5)
= 2 × 2 × 4 = 16 ✓
6

Interpret

Interpret the result: 16 numbers 60 are coprime to 60

Numbers: 1,7,11,13,17,19,
23,29,31,37,41,43,47,49,53,59

Pro Tips for Totient Calculations

  • Memorize φ(p) = p-1 for prime p
  • Use multiplicative property: φ(ab)=φ(a)φ(b) if gcd(a,b)=1
  • For prime powers: φ(p^k) = p^k - p^(k-1)
  • Check small values: φ(1)=1, φ(2)=1, φ(3)=2, φ(4)=2, φ(5)=4, φ(6)=2
  • Use online tools: Verify complex calculations with calculators

Euler Totient Function FAQs (φ(n) Explained)

Common questions about Euler's totient function, Carmichael function, and number theory concepts.

What is Euler's totient function φ(n)?
Euler's totient function φ(n) counts how many positive integers less than or equal to n are coprime to n (i.e., they share no common factor with n except 1).
How do you calculate φ(n)?
φ(n) is calculated using the formula φ(n) = n × ∏(1 − 1/p), where p are the distinct prime factors of n.
What is the difference between φ(n) and λ(n)?
φ(n) counts coprime integers, while λ(n) is the smallest exponent such that a^λ(n) ≡ 1 (mod n) for all coprime a. λ(n) always divides φ(n).
What is Euler’s theorem?
Euler’s theorem states that if a and n are coprime, then a^φ(n) ≡ 1 (mod n). It generalizes Fermat’s Little Theorem.
Can φ(n) be larger than n?
No, φ(n) is always less than or equal to n. It equals n only when n = 1.
What is φ(1)?
φ(1) = 1 because 1 is coprime with itself.
What is φ(p) for a prime number?
If p is prime, then φ(p) = p − 1 because all numbers less than p are coprime to it.
What is φ(p^k)?
φ(p^k) = p^k − p^(k−1), where p is a prime number.
Is Euler’s totient function multiplicative?
Yes, φ(ab) = φ(a)φ(b) if gcd(a, b) = 1, meaning a and b are coprime.
How is φ(n) used in RSA encryption?
In RSA, φ(n) is used to compute the private key. It helps determine modular inverses for secure encryption and decryption.
What is the Carmichael function λ(n)?
λ(n) is the smallest number such that a^λ(n) ≡ 1 (mod n) for all integers a that are coprime to n.
What are primitive roots?
Primitive roots are numbers whose powers generate all numbers coprime to n under modular arithmetic.
Why is Euler’s totient function important?
It is fundamental in number theory, modular arithmetic, cryptography, and algorithms like RSA.
Can this calculator handle large numbers?
Yes, this calculator uses optimized algorithms to efficiently compute φ(n) even for large inputs.