Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 3

Euler's Totient Function and Prime Factorization

Recommended resources

Welcome back. In our previous lesson, we introduced Euler's totient function, , as the cornerstone of Euler's theorem. This allowed us to simplify large modular exponentiations, a technique vital for modern cryptography. However, we were only able to compute for simple cases, such as primes where .

This lesson delivers on the promise to generalize this computation. Our goal is to derive and apply a formula for calculating for any arbitrary integer , using its prime factorization. This computational skill is not merely a number-theoretic curiosity; it is a fundamental component in the construction of cryptosystems like RSA, where computing is a key step in generating the public and private keys.

The First Building Block: Powers of a Prime

We know how to compute for a prime . The next logical step is to consider a power of a prime, , where is a positive integer.

To compute , we need to count the integers from 1 to that are relatively prime to . An integer shares a common factor with if and only if it is a multiple of . So, our task simplifies to counting how many numbers up to are not multiples of .

The following video provides a clear derivation of this count.

Introduction to Euler's Totient Function!

This video explains how to derive the formula for the totient of a prime power by counting the total numbers in the interval and subtracting those that are not coprime.

Please watch the section from this timestamp. Focus on the argument: the numbers that are not coprime to p^k are precisely the multiples of p. The video counts these multiples and subtracts them from the total.

As the video explains, the multiples of in the range are . There are exactly such multiples.

The total number of integers in the interval is . Therefore, the number of integers that are coprime to is:

This formula can also be written in two other useful forms:

or

This formula is our first major tool for computing .


The Second Building Block: The Multiplicative Property

Now that we can handle integers that are powers of a single prime, we need a way to handle integers with multiple distinct prime factors, like . The key to this is a beautiful property of the totient function.

Theorem: Multiplicativity of
If and are two positive integers such that , then:

An integer is coprime to the product if and only if it is coprime to and coprime to . This fact is the foundation of the proof for this theorem. The following resource provides an elegant and rigorous proof that leverages this idea by arranging the integers from 1 to into a grid. Given your background, the structure of this proof should be quite satisfying.

4 Euler's Totient Function

This document provides a formal proof for the multiplicative property of Euler's totient function. The argument is both intuitive and rigorous.

First, read the subsection titled "Proving the multiplicative property" on page 3. Pay attention to the example where the numbers modulo 36 are laid out in a rectangle. This visual argument is the core idea. Then, read the formal proof that follows on page 4, which abstracts this very example.


The General Formula for

We now have all the necessary components to build the general formula. Any integer has a unique prime factorization:

where are distinct prime numbers and are positive integers.

Since the terms are all pairwise coprime (e.g., ), we can repeatedly apply the multiplicative property:

Now, we can substitute our formula for prime powers, , for each term in the product. The following video walks through this final synthesis to arrive at the explicit formula.

Explicit Formula for Euler's Totient Function!

This video masterfully combines the two properties we've just discussed—the formula for prime powers and multiplicativity—to derive the general formula for \phi(n).

Watch the derivation from this section. The presenter starts with the prime factorization of n, applies the multiplicative property, substitutes the formula for prime powers, and simplifies the result into its final, elegant form.

The final result from this derivation is the explicit formula for Euler's totient function:

where the product is over the set of distinct prime factors of .


Putting the Formula into Practice

Let's apply this formula to a few examples.

Example 1: Computing

The prime factorization of 360 is . The distinct prime factors are 2, 3, and 5.
Using the formula:

So, there are 96 integers between 1 and 360 that are coprime to 360.

Example 2: The RSA Case

A crucial case for cryptography is when is the product of two distinct, large primes, . This is the modulus used in the RSA algorithm. Let's compute in this case.
The distinct prime factors are simply and .

This extremely important result, , is used directly in RSA key generation. Notice how easy it is to compute if you know the prime factors and . However, if you only know , computing is computationally equivalent to factoring , which is believed to be a hard problem. This difficulty is the source of RSA's security.

To solidify your understanding, please study the following worked example.

[PDF] Dr. Z.'s Number Theory Lecture 15 Handout: Euler's Totient Function

This document provides another clear example of the computation.

Please review Problem 15.2 on page 2. It demonstrates the step-by-step calculation for \phi(300).


Conclusion

In this lesson, we have constructed the complete toolkit for computing Euler's totient function for any integer. We saw that the general formula is built upon two simpler, yet powerful, ideas: the formula for prime powers, , and the multiplicative nature of the function, for coprime and .

Key Takeaways:

  • To compute , you must first find the prime factorization of .
  • The formula for a prime power is .
  • The function is multiplicative: if .
  • The general formula is .
  • For the RSA modulus , we have the critical identity .
  • The ease of computing when the factors of are known, versus the difficulty when they are not, is a central principle in public-key cryptography.

In our next lesson, we will explore the Chinese Remainder Theorem. This theorem is a powerful tool for solving systems of linear congruences. As a point of interest, it also provides an alternative, more algebraic proof for the multiplicative property of , further highlighting the deep connections between the concepts in this module.