Recall that Euler’s \(\phi(n)\) (totient) function is the number of residue classes (mod \(n\)) coprime to \(n\) or the number of positive integers \(\leq n\) that are relatively prime to \(n\). Computing the values of \(\phi(n)\) for \(n=1,2,\cdots,10\).

\(n\) Residue Classes mod n (coprime to n) \(\phi(n)\)
111
211
31, 22
41, 32
51, 2, 3, 44
61, 52
71, 2, 3, 4, 5, 66
81, 3, 5, 74
91, 2, 4, 5, 7, 86
101, 3, 7, 94

Recall also that \(\phi(p)=p-1\) when \(p\) is prime. What about non-prime numbers? Recall \(\phi\) is a multiplicative function so for any \(m\) and \(n\),

$$ \begin{align*} \phi(mn) = \phi(m)\phi(n) \quad \text{ if } (m,n) = 1 \end{align*} $$

This is actually due to the Chinese remainder theorem (TODO).
Now suppose that \(n\) is not prime and that

$$ \begin{align*} n = p_1^{e_1}p_2^{e_2}\cdots p_k^{e_k} \end{align*} $$

Then

$$ \begin{align*} \phi(n) = \phi(p_1^{e_1})\phi(p_2^{e_2}) \cdots \phi(p_k^{e_k}) \end{align*} $$

So now what is \(\phi(p^i)\) for some power \(i\)? It is the number of integers coprime to \(p^i\). So we need to test all the numbers in \(\{0,\cdots,p^{i-1}\}\). But since \(p\) is prime, the number of integers not coprime to \(p^i\) are exactly those that are multiples of \(p\) so

$$ \begin{align*} p, 2p, 3p, \cdots p^{i-1} \end{align*} $$

We have \(p^i\) possible numbers less than or equal to \(p^i\), \(\{1,2,\cdots,p^i\}\). Out of these factors, there are exactly \(p^{i-1}\) numbers that are not coprime to \(p^i\). Therefore, the total number of numbers coprime to \(p^i\) is

$$ \begin{align*} \phi(p^i) &= p^i - p^{i-1} \\ &= p^{i-1} (p - 1) \\ &= p^{i} \left(1 - \frac{1}{p}\right) \end{align*} $$

Then

$$ \begin{align*} \phi(n) &= \phi(p_1^{e_1}) \cdot \phi(p_2^{e_2}) \cdot \cdots \cdot \phi(p_k^{e_k}) \\ &= p_1^{e_1} \left( 1- \frac{1}{p_1}\right) \cdot p_2^{e_2} \left(1- \frac{1}{p_2}\right) \cdots p_k^{e_k} \left(1- \frac{1}{p_k} \right) \\ &= ( p_1^{e_1}p_2^{e_2} \cdots p_k^{e_k} ) \cdot \left( 1- \frac{1}{p_1}\right) \cdot \left(1- \frac{1}{p_2}\right) \cdots \left(1- \frac{1}{p_k} \right) \\ &= n \cdot \left( 1- \frac{1}{p_1}\right) \cdot \left(1- \frac{1}{p_2}\right) \cdots \left(1- \frac{1}{p_k} \right) \end{align*} $$

Alternative Explanation 1

Another way to think about Euler’s formula is using the inclusion exclusion principle. Take for example \(\phi(6)\). We start with 6 possibilities and then we have to throw away all the numbers divisible by 2

$$ \begin{align*} \phi(6) = 6 - \frac{6}{2} - \cdots \end{align*} $$

Then we have to throw away the numbers divisible so \(6\) so \(3\)

$$ \begin{align*} \phi(6) = 6 - \frac{6}{2} - \frac{6}{3} - \cdots \end{align*} $$

But now we have to add the numbers divisible by 6 back since we removed two copies of them because they are divisible by 2 and 3.

$$ \begin{align*} \phi(6) = 6 - \frac{6}{2} - \frac{6}{3} + \frac{6}{3} = 2 \end{align*} $$

Let’s do \(\phi(30)\) now. We need take out all the numbers divisible by 2, 3 and 5 and then add the numbers taken out twice, \(2 \cdot 3 = 6\), \(3 \cdot 5 = 15\), \(2 \cdot 5 = 10\). But notice now that we’ve thrown 30 three times but we added it four times. We need to throw it away

$$ \begin{align*} \phi(30) &= 30 - \frac{30}{2} - \frac{30}{3} - \frac{30}{5} + \frac{30}{15} + \frac{30}{10} + \frac{30}{6} - \frac{30}{30} \\ &= 30 - 15 - 10 - 6 + 2 + 3 + 5 - 1 \\ &= 9 \end{align*} $$

The ones remaining coprime to \(30\) are \(\{1, 7, 11, 13, 17, 19, 23, 29\}\). The professor used a venn diagram which was nice (TODO).


Alternative Explanation 2: Probability

Take \(\phi(30)\) again. What is the probability that a number is coprime to \(30\)? This number is not coprime to \(30\) if

  1. Divisible by \(2\). The probability that a number is divisible by 2 is \(\frac{1}{2}\)
  2. Divisible by \(3\). The probability that a number is divisible by 3 is \(\frac{1}{3}\)
  3. Divisible by \(5\). The probability that a number is divisible by 5 is \(\frac{1}{5}\)

They key point is that these are independent events. Given two events \(A\) and \(B\). If these events are independent, then

$$ \begin{align*} P(A \cap B) = P(A) \cdot P(B) \end{align*} $$

For three events, we need

$$ \begin{align*} P(A \cap B \cap C) &= P(A) \cdot P(B) \cdot P(C) \end{align*} $$

We want the probability that none of these three events occur. This is

$$ \begin{align*} &= (1 - P(A)) \cdot (1 - P(B)) \cdot (1 - P(C)) \\ &= \left(1 - \frac{1}{2}\right) \left(1 - \frac{1}{3}\right) \left(1 - \frac{1}{5}\right) \end{align*} $$

But this is for all numbers. If we restrict this to numbers less than 30, then the number of numbers coprime to 30 is

$$ \begin{align*} &= 30 \left(1 - \frac{1}{2}\right) \left(1 - \frac{1}{3}\right) \left(1 - \frac{1}{5}\right) \\ &= 8 \end{align*} $$

Example

Compute \(\phi(10!)\). We need to compute the prime factorization of 10!. This is

$$ \begin{align*} &= 2 \cdot 3 \cdot 2^2 \cdot 5 \cdot (2 \cdot 3) \cdot 7 \cdot 2^3 \cdot 3^2 \cdot (2 \cdot 5) \\ &= 2^8 \cdot 3^4 \cdot 5^2 \cdot 7 \end{align*} $$

Then

$$ \begin{align*} \phi(10!) &= 2^7(2-1) \cdot 3^3(3-1) \cdot 5^1(5-1) \cdot 7^0(7-1) \end{align*} $$

So as long as we know the prime factorization, then it is very easy to find out \(\phi(n)\).


Example

Find all numbers \(n\) with \(\phi(n)=24\)

The prime factorization of \(24\) is

$$ \begin{align*} 2 \cdot 2 \cdot 2 \cdot 3 \end{align*} $$

But for any \(n\), we know that

$$ \begin{align*} \phi(n) &= p^{e-1}(p - 1) \cdots \\ 24 &= p^{e-1}(p - 1) \cdots \end{align*} $$

So we’re trying to factor out \(24\) as \(p^{e-1}(p - 1) \cdots\). But the factors of \(24\) are

$$ \begin{align*} \{1,2,3,4,6,8,12\} \end{align*} $$

So we need numbers \((p-1)\) that divide \(24\) but \(p\) itself is prime. In the list above, \(8\) divides \(24\) but \(8+1 = 9\) is not prime. So \(8\) can’t show up and can be eliminated. Similarly, \(3\) can be eliminated because \(3+1=4\) is not prime. We’ll end up with the following list

$$ \begin{align*} \{1,2,4,6,12\} \end{align*} $$

Consider \(p-1 = 12\). Then, \(p = 13\) and

$$ \begin{align*} \phi(n) &= 24 = (13)^{e-1}(13 - 1) \cdots \end{align*} $$

But it is obvious here that \(e\) can’t be bigger than \(2\) since \(13^2 > 24\). So we can only have the powers \(0\) or \(1\) for 13. We can apply a similar logic to the remaining primes to see that we can only have the following powers

$$ \begin{align*} \{ 13^{\{0,1\}}, 7^{\{0,1\}}, 5^{\{0,1\}}, 3^{\{0,1,2\}}, 2^{\{0,1,2,3,4\}} \} \end{align*} $$

This is a pretty small list to iterate over and just brute force possible solutions. For example,

$$ \begin{align*} 24 = 13^{0}(13-1) \cdot 2^{1}(2-1) \end{align*} $$

This means that \(n\) itself is \(13^1 \cdot 2^2 = 52\). Another choice is

$$ \begin{align*} 24 = 7^{0}(7-1) \cdot 2^{2}(2-1) \end{align*} $$

This will give us \(n = 7 \cdot 2^3 = 56\) and so on.


Example: Carmichael's Conjecture

Given \(n\), there is at least one other integer \(m \neq n\) with \(\phi(m) \neq \phi(n)\)

So far we know that the answer is yes and so far people have computed this for very large numbers with 10 billion digits. So if we were to find a counter example, it will be unbelievably huge. Observe now that if \(n\) is odd, then \(\phi(n) = \phi(2n)\). Why is that? because

$$ \begin{align*} \phi(2n) = \phi(2) \cdot \phi(n) = 1 \cdot \phi(n) \end{align*} $$

We can use the same type of argument with divisibility rule to exclude more numbers but no one had ever proved it for all cases.


Example

Can we find numbers \(n\) such that \(\phi(n)\) is a power of \(2\)?

Why do we care? Gauss showed that we can construct a regular \(n\)-gon with ruler and compass if and only if \(\phi(n)\) is a power of 2. (though constructing the \(n\)-gon with a ruler and compass is rather pointless). So we want

$$ \begin{align*} \phi(n) = 2^k \end{align*} $$

But now given that the prime factorization of \(n\) is

$$ \begin{align*} p_1^{e_1} \cdot p_1^{e_2} \cdots p_k^{e_k} \end{align*} $$

Then, using Euler’s formula

$$ \begin{align*} \phi(n) &= 2^k = p_1^{e_1-1}(p_1 - 1) \cdot p_2^{e_2-1}(p_2 - 1) \cdots \end{align*} $$

Notice that if \(p_i \neq 2\), then we must have \(e_i = 1\) (since if this wasn’t the case then \(\phi(n)=2^k\) will be divisible by a prime other than 2). So we should expect something like

$$ \begin{align*} \phi(n) &= 2^{a}(2 - 1) \cdot 2^{b}(2 - 1) \cdots p_1^{e_1-1}(p_1 - 1) \cdot p_2^{e_2-1}(p_2 - 1) \cdots \\ \phi(n) &= 2^{a} \cdot 2^{b} \cdots p_1^{1-1}(p_1 - 1) \cdot p_2^{1-1}(p_2 - 1) \cdots \\ 2^k &= 2^{a+b+\cdots} \cdot (p_1 - 1) (p_2 - 1) \cdots \end{align*} $$

So we will have some power of \(2\) multiplied by the remaining product. Observe that \((p_i - 1)\) must be a power of \(2\) since it divides \(\phi(n)=2^k\). So each of these \((p_i - 1)\) has the form

$$ \begin{align*} p_i - 1 &= 2^t \\ p_i &= 2^t + 1 \end{align*} $$

But now we know that \(p_i\) is a prime and since it has the form \(2^t + 1\), then it is a Fermat prime and \(t\) is a power of two itself. If we re-write \(n\), then

$$ \begin{align*} n &= 2^x \cdot p_1 \cdot p_2 \cdots \\ &= 2^x \cdot (2^{t_1} + 1) \cdot (2^{t_2} + 1) \cdots \end{align*} $$

How big is \(\phi(n)?\)

We can also ask

How big can \(\phi(n)\) get?

The upper bound is pretty obvious. \(\phi(n) < n\). When \(p\) is prime, then \(\phi(n) = p-1\). So \(\phi(n)/n \leq 1\) can get very close to 1 since when \(n\) is prime.

How small can \(\phi(n)/n\) get? We know

$$ \begin{align*} \phi(n)/n &= \left(1 - \frac{1}{p_1}\right) \left(1 - \frac{1}{p_2}\right) \cdots \end{align*} $$

where \(p_1,p_2,\cdots\) are the primes dividing \(n\). So to make this number smaller, we want \(n\) to be divisible by lots of small primes. Taking a few examples

$$ \begin{align*} 2&: \quad \phi(2)/2 = \frac{1}{2} \\ 2 \cdot 3&:\quad \phi(6)/6 = \frac{1}{2} \cdot \frac{2}{3} = \frac{1}{3} \\ 2 \cdot 3 \cdot 5&: \quad \phi(30)/30 = \frac{1}{2} \cdot \frac{2}{3} \cdot \frac{4}{5} = \frac{8}{30} \\ 2 \cdot 3 \cdot 5 \cdot 7&: \quad \phi(210)/210 = \cdots \\ \end{align*} $$

But now, can we make \(\phi(n)/n\) as small as we like? for example less than \(\frac{1}{100}\)? To answer this, we want to know how small could the following number get

$$ \begin{align*} &\left(1 - \frac{1}{2}\right) \left(1 - \frac{1}{3}\right) \left(1 - \frac{1}{5}\right) \left(1 - \frac{1}{7}\right) \cdots \end{align*} $$

Could this number get smaller and smaller until it reaches zero or could there be some lower limit? We can figure this out by looking at its inverse (why its inverse? because sometimes it is easier to see big a number can get rather than how close it can get to zero). Then, taking the inverse

$$ \begin{align*} &= \left(\frac{1}{1 - \frac{1}{2}}\right) \left(\frac{1}{1 - \frac{1}{3}}\right)\left(\frac{1}{1 - \frac{1}{5}}\right)\left(\frac{1}{1 - \frac{1}{7}}\right) \cdots \end{align*} $$

But now we can use the identity

$$ \begin{align*} \frac{1}{1 - x} &= 1 + x + x^2 + \cdots \end{align*} $$

To see that

$$ \begin{align*} &= \left(\frac{1}{1 - \frac{1}{2}}\right) \left(\frac{1}{1 - \frac{1}{3}}\right)\left(\frac{1}{1 - \frac{1}{5}}\right)\left(\frac{1}{1 - \frac{1}{7}}\right) \cdots \\ &= \left(1 + \frac{1}{2} + \frac{1}{2^2} +\cdots\right)\left(1 + \frac{1}{3} + \frac{1}{3^2} +\cdots\right)\cdots \\ &= \prod_p \left(1 + \frac{1}{p} + \frac{1}{p^2} +\cdots\right) \end{align*} $$

Using the Euler product formula when \(s = 1\), then (TODO: what is this)

$$ \begin{align*} &= \prod_p \left(1 + \frac{1}{p} + \frac{1}{p^2} +\cdots\right) \\ &= \sum_{\text{all prime factors }\leq p} \frac{1}{n} \end{align*} $$

But this grows without bound. So this means that

$$ \begin{align*} &= \prod_{p \text{ prime}} \left(1-\frac{1}{p}\right) \end{align*} $$

goes to 0 so we can make it as small as we like


Average of \(\phi(n)/n\)

Another question we can ask is

What is the average of \(\phi(n)/n\)?

We saw two extremes here. We saw that we can make \(\phi(n)/n\) go to zero by just adding many small prime factors. We also saw that can we make \(\phi(n)/n\) get very close to 1 just by choosing \(n\) to be prime. What about the average value of \(\phi(n)/n\)? We can think of this asking “What is the chance that a randomly chosen integer less than \(n\) is coprime to \(n\)?” or more general we can ask

So what is the chance of that two numbers \(m\) and \(n\) chosen at random are coprime?

The first issue is that we can’t really choose two numbers at random because this would mean that every integer is equally likely of being selected. This implies that every integer has the same chance of being selected, equal to some \(\epsilon\). This means \(\epsilon\) is zero. We can fix this if we have some upper bound \(N\) on \(m\) and \(n\). Furthermore, being coprime to each other means that they are both divisible by \(2\) for instance, so we can ask

So what is the chance of having two numbers \(m\) and \(n\) not divisible by \(2\)?

The chance of having both numbers be divisible by \(2\) is

$$ \begin{align*} \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{4} \end{align*} $$

Therefore, the chance of having both not divisible by \(2\) is \(1-\frac{1}{4}\). Similarly, the chance of having both numbers not divisible by \(3\) is \(1 - \frac{1}{3^2}\) and so on. Then, the probability that \(m\) and \(n\) are coprime is about

$$ \begin{align*} \left(1 - \frac{1}{2^2}\right) \cdot \left(1 - \frac{1}{3^2}\right) \cdot \left( 1 - \frac{1}{5^2}\right) \cdots \end{align*} $$

Obviously there are issues here since if we limit \(m\) and \(n\) to some bound \(N\), then we need to stop testing after some limit. Also the chance of being divisible by \(3\) changes a tiny bit if we have an upper bound on both numbers. But, we ignore this for now to focus on whether the product above tends to zero or some other limit. Well, we saw before that

$$ \begin{align*} \left(1 - \frac{1}{2}\right) \cdot \left(1 - \frac{1}{3}\right) \cdot \left( 1 - \frac{1}{5}\right) \cdots \rightarrow 0 \end{align*} $$

So we might think our product must also go to zero but in fact it doesn’t. To see why, we can take the inverse of the product to analyze it just like we did before so

$$ \begin{align*} &= \frac{1}{\left(1 - \frac{1}{2^2}\right)} \cdot \frac{1}{\left(1 - \frac{1}{3^2}\right)} \cdot \frac{1}{\left( 1 - \frac{1}{5^2}\right)} \cdots \\ &= \left(1 + \frac{1}{2^2} + \frac{1}{2^4} + \cdots\right) \cdots \left(1 + \frac{1}{3^2} + \frac{1}{3^4} + \cdots\right) \cdots \\ &= \prod_p \left(1 + \frac{1}{p^2} + \frac{1}{p^4} + \cdots\right) \end{align*} $$

So now at this step, multiplying all of these, we get all the numbers with prime factorization consisting of primes squared (and their powers). Therefore, this product gives

$$ \begin{align*} &= \sum_n^{\infty} \frac{1}{n^2} \end{align*} $$

Euler managed to actually compute this sum and finding that it’s equal to

$$ \begin{align*} \sum_n^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6} \end{align*} $$

Generating Functions

TODO


References