Euler's Totient Function Calculator (φ)

Calculate φ(n) instantly. Our calculator provides a step-by-step solution using the prime factorization and product formula for Euler's totient function.

"Read Euler, read Euler, he is the master of us all." - Pierre-Simon Laplace

Calculate Euler's Totient Function φ(n)

φ(k) for k up to n

Ad Space 1 (e.g., 728x90 or Responsive)

The Ultimate Guide to Euler's Totient Function (φ)

Welcome to the definitive guide on Euler's Totient Function, also known as Euler's phi (φ) function. This important function in number theory counts the positive integers up to a given integer 'n' that are relatively prime to 'n'. Our powerful Euler's Totient Function Calculator above will not only give you the answer but also show you the step-by-step process.

What is Euler's Totient Function?

The totient φ(n) of a positive integer 'n' is defined as the number of positive integers less than or equal to 'n' that are coprime to 'n'. Two numbers are "coprime" or "relatively prime" if their greatest common divisor (GCD) is 1.

Let's take a simple example: φ(9).

  • We need to find the numbers from 1 to 9 that share no factors with 9 other than 1.
  • The numbers are: 1, 2, 3, 4, 5, 6, 7, 8, 9.
  • GCD(1, 9) = 1 (Coprime)
  • GCD(2, 9) = 1 (Coprime)
  • GCD(3, 9) = 3 (Not coprime)
  • GCD(4, 9) = 1 (Coprime)
  • GCD(5, 9) = 1 (Coprime)
  • GCD(6, 9) = 3 (Not coprime)
  • GCD(7, 9) = 1 (Coprime)
  • GCD(8, 9) = 1 (Coprime)
  • GCD(9, 9) = 9 (Not coprime)

The coprime numbers are {1, 2, 4, 5, 7, 8}. There are 6 such numbers. Therefore, φ(9) = 6.

Ad Space 2 (e.g., 300x250 or Responsive)

How to Calculate φ(n): The Product Formula

Listing all numbers is inefficient. A much faster way to calculate the totient function is by using its product formula, which depends on the prime factorization of 'n'. This is the method our calculator uses.

If the prime factorization of 'n' is n = p₁k₁ × p₂k₂ × ... × pᵣkᵣ, where p₁, p₂, ... are distinct prime factors, then the formula for Euler's totient function is:

Example Calculation using the Formula

Let's calculate φ(36).

  1. Find the prime factorization of 36: 36 = 2² × 3²
  2. Identify the distinct prime factors: The distinct primes are p₁=2 and p₂=3.
  3. Apply the product formula:
    • φ(36) = 36 × (1 - 1/2) × (1 - 1/3)
    • φ(36) = 36 × (1/2) × (2/3)
    • φ(36) = 18 × (2/3) = 12

So, there are 12 numbers between 1 and 36 that are relatively prime to 36.

Key Properties of Euler's Totient Function

The phi function has several useful properties that simplify calculations:

  • 🅿️ For a prime number p: If 'p' is a prime number, then all numbers from 1 to p-1 are coprime to it. Therefore, φ(p) = p - 1. For example, φ(7) = 6.
  • ✖️ Multiplicative Property: If 'm' and 'n' are coprime, then φ(mn) = φ(m) × φ(n). For example, φ(9) = 6 and φ(5) = 4. Since 9 and 5 are coprime, φ(45) = φ(9) × φ(5) = 6 × 4 = 24.
  • 💥 For a prime power pk: The value is given by φ(pk) = pk - pk-1 = pk(1 - 1/p).

Applications of Euler's Totient Function

Euler's totient function is not just a mathematical curiosity; it's a cornerstone of modern cryptography.

  • Euler's Totient Theorem: This is a generalization of Fermat's Little Theorem. It states that if 'a' and 'n' are coprime, then aφ(n) ≡ 1 (mod n). This theorem is fundamental to the security of the RSA encryption algorithm, which is used to secure countless online transactions and communications.
  • Cyclic Groups: In abstract algebra, φ(n) gives the number of generators of the cyclic group Zn.
  • Periodicity of Fractions: The length of the repeating decimal expansion of 1/n is related to φ(n).

Euler's Totient Function in Python

Here is an efficient implementation of an Euler's totient function in Python, using the product formula principle.


def euler_totient(n):
    """Calculates Euler's totient function φ(n)."""
    result = n
    p = 2
    while p * p <= n:
        if n % p == 0:
            while n % p == 0:
                n //= p
            result -= result // p
        p += 1
    if n > 1:
        result -= result // n
    return result

# Example
number = 97
print(f"φ({number}) = {euler_totient(number)}")
# Output: φ(97) = 96
                    

Conclusion: A Pillar of Number Theory

From its simple definition of counting coprime numbers to its critical role in modern cryptography, Euler's Totient Function is a beautiful and powerful concept in mathematics. This calculator is designed to be the best tool for exploring it, providing instant results, detailed step-by-step solutions, and visualizations that help you appreciate the elegant patterns of number theory. Whether you're a student learning for the first time or a professional needing a quick calculation, this tool provides the clarity and power you need.

Support Our Work

Help keep this advanced calculator free and updated with a small contribution.

Donate via UPI

Scan the QR code for UPI payment in India.

UPI QR Code

Support via PayPal

Contribute securely via PayPal.

PayPal QR Code for Donation