Notes - Number Theory: Euler Totient Function from First Principles
Euler’s Totient Function (denoted as φ(n)) is used to determine the number of positive integers less than n
that are co-prime to n
. Co-prime numbers are numbers that have no common factor with n
other than 1.
The formula for Euler’s Totient Function, when n
is a product of distinct prime numbers, is:
φ(n) = n * (1 - 1/p1) * (1 - 1/p2) * ... * (1 - 1/pk)
This formula is derived based on principles of probability and basic properties of prime numbers. Let’s break it down:
-
Identifying Reducible Fractions: Consider a fraction with
n
as the denominator and a numbera
(between 1 andn
) as the numerator. This fraction is reducible if and only ifa
andn
share a common factor other than 1. In other words, it is reducible ifa
is not co-prime withn
. -
Excluding Fractions Reducible by a Prime: If
n
is divisible by a prime numberp
, then1/p
of the numbers from 1 ton
are also divisible byp
(because every pth number will be divisible byp
). This means1/p
of the fractions withn
in the denominator are reducible byp
. -
Accounting for Multiple Prime Factors: If
n
has multiple distinct prime factors, we need to subtract the fractions ofn
that are reducible by each of these primes. But doing this might lead us to subtract some fractions more than once (those reducible by the least common multiple of two primes). So, we need to add back these fractions. This is based on the principle of inclusion and exclusion, a fundamental principle in combinatorics. -
Principle of Inclusion an Exclusion The principle of inclusion and exclusion is a counting principle in combinatorics. Here’s a simplified explanation of that principle:
- If you want to count the total number of objects in two sets, you add the number of objects in each set.
- But, if some objects belong to both sets, you’ve counted them twice. To correct this, you subtract the number of objects that belong to both sets.
So how does this apply to Euler’s totient function?
Let’s take an example where n = p*q
and p
and q
are distinct primes. We want to find φ(n), which is the count of numbers less than n
that are co-prime to n
.
- Start with the number
n
. This is the total count of numbers less thann
. - From this, subtract the count of numbers less than
n
that are divisible byp
(which isn/p
). We subtract these because these numbers share a factor withn
and hence are not co-prime ton
. - Also subtract the count of numbers less than
n
that are divisible byq
(which is n/q). - But, we’ve subtracted too much! Some numbers are divisible by both
p
andq
(specifically, the multiples ofp*q
), and we’ve subtracted these numbers twice. So, to correct this, we add back the count of numbers less thann
that are divisible byp*q
(which isn/(p*q)
).
Therefore, applying the principle of inclusion and exclusion, the total count of numbers less than n
that are co-prime to n
is:
φ(n) = n - n/p - n/q + n/(p*q)
We can factor out n
from each term to get Euler’s totient function formula:
φ(n) = n * (1 - 1/p) * (1 - 1/q)
This is the way the formula is derived when n
has two distinct prime factors. The process is similar for numbers with more than two distinct prime factors.
References: