Euler Function Calculator

Calculate Euler's Totient Function (φn)

Enter a positive integer below to find out how many positive integers up to it are relatively prime to it.

Enter a number and click 'Calculate' to find its Euler's Totient Function value.

Welcome to the Euler's Totient Function Calculator! This tool helps you quickly determine the value of Euler's phi function (φn) for any positive integer 'n'. But what exactly is this fascinating mathematical concept, and why is it so important?

What is Euler's Totient Function?

Euler's Totient Function, often denoted as φ(n) or φn, is a fundamental function in number theory that counts the positive integers up to a given integer 'n' that are relatively prime to 'n'. Two integers are considered relatively prime (or coprime) if their greatest common divisor (GCD) is 1. In simpler terms, φ(n) tells you how many numbers between 1 and 'n' (inclusive) share no common factors with 'n' other than 1.

Understanding "Relatively Prime"

Let's take an example. If n = 6, we list the positive integers less than or equal to 6: 1, 2, 3, 4, 5, 6.

  • GCD(1, 6) = 1 (coprime)
  • GCD(2, 6) = 2 (not coprime)
  • GCD(3, 6) = 3 (not coprime)
  • GCD(4, 6) = 2 (not coprime)
  • GCD(5, 6) = 1 (coprime)
  • GCD(6, 6) = 6 (not coprime)

So, for n = 6, the numbers relatively prime to 6 are 1 and 5. Therefore, φ(6) = 2.

How to Calculate Euler's Totient Function

While you can list out all numbers and check their GCDs for small 'n', this becomes impractical for larger numbers. Fortunately, there's a powerful formula based on the prime factorization of 'n'.

The Formula

If the prime factorization of 'n' is given by n = p1k1 × p2k2 × ... × prkr, where pi are distinct prime factors and ki are their exponents, then Euler's Totient Function is calculated as:

φ(n) = n × (1 - 1/p1) × (1 - 1/p2) × ... × (1 - 1/pr)

Alternatively, it can also be expressed as:

φ(n) = p1k1-1(p1-1) × p2k2-1(p2-1) × ... × prkr-1(pr-1)

Examples Using the Formula:

  • For n = 10:

    Prime factorization of 10 is 21 × 51. The distinct prime factors are 2 and 5.

    φ(10) = 10 × (1 - 1/2) × (1 - 1/5)

    φ(10) = 10 × (1/2) × (4/5)

    φ(10) = 10 × (4/10) = 4

    The numbers less than or equal to 10 and relatively prime to 10 are: 1, 3, 7, 9. (There are 4 of them).

  • For n = 12:

    Prime factorization of 12 is 22 × 31. The distinct prime factors are 2 and 3.

    φ(12) = 12 × (1 - 1/2) × (1 - 1/3)

    φ(12) = 12 × (1/2) × (2/3)

    φ(12) = 12 × (2/6) = 12 × (1/3) = 4

    The numbers less than or equal to 12 and relatively prime to 12 are: 1, 5, 7, 11. (There are 4 of them).

Properties of Euler's Totient Function

Euler's Totient Function has several interesting properties that make it a cornerstone of number theory:

  • φ(1) = 1: The only positive integer less than or equal to 1 that is relatively prime to 1 is 1 itself.
  • If 'p' is a prime number: φ(p) = p - 1. This is because all integers from 1 to p-1 are relatively prime to p.
  • If 'p' is a prime number and 'k' is a positive integer: φ(pk) = pk - pk-1 = pk-1(p-1).
  • Multiplicative Function: If 'm' and 'n' are relatively prime (GCD(m, n) = 1), then φ(mn) = φ(m)φ(n). This property is crucial for the formula based on prime factorization.
  • Sum over Divisors: The sum of φ(d) for all positive divisors 'd' of 'n' equals 'n'. That is, Σd|n φ(d) = n.

Applications of Euler's Totient Function

Beyond its theoretical elegance, φn has significant practical applications:

  • Cryptography (RSA Algorithm): This is perhaps its most famous application. The RSA public-key cryptosystem, widely used for secure data transmission, relies heavily on Euler's Totient Theorem (which states that if 'a' and 'n' are coprime positive integers, then aφ(n) ≡ 1 (mod n)). The security of RSA comes from the difficulty of factoring large numbers into their prime components, which in turn makes calculating φ(n) for very large 'n' (the product of two large primes) computationally intensive without knowing the prime factors.
  • Number Theory: It plays a vital role in various theorems and concepts within number theory, including Fermat's Little Theorem (a special case of Euler's Totient Theorem for prime moduli), group theory, and the study of primitive roots.
  • Discrete Mathematics: Concepts related to φn appear in areas like combinatorics and the study of finite fields.

How This Calculator Works

Our Euler's Totient Function calculator utilizes the prime factorization method. When you input a number, the underlying JavaScript code efficiently finds all distinct prime factors of that number. It then applies the formula φ(n) = n × ∏p|n(1 - 1/p) to compute the result. This ensures accuracy and speed, even for moderately large numbers.

We hope this tool and explanation empower you to better understand and utilize this fundamental concept in mathematics. Whether you're a student, a cryptography enthusiast, or just curious about the elegance of numbers, Euler's Totient Function offers a rich field of exploration!