Art of Problem Solving
During AMC 10A/12A testing, the AoPS Wiki is in read-only mode and no edits can be made.

Euler's totient function: Difference between revisions

No edit summary
m proofreading
Line 1: Line 1:
'''Euler's totient function''', <math>\displaystyle \phi(n)</math>, is defined as the number of positive integers less than or equal to a given positive integer that are [[relatively prime]] to that integer.  <math>\displaystyle \phi(n)</math> is read "phi of n."
'''Euler's totient function''', <math>\displaystyle \phi(n)</math>, is defined as the number of positive integers less than or equal to a given positive integer that is [[relatively prime]] to that integer.  <math>\displaystyle \phi(n)</math> is read "phi of n."


== Formulas ==
== Formulas ==
To derive the formula, let us first define the prime factorization of <math> n </math> as <math> n = p_1^{e_1}p_2^{e_2}\cdot p_n^{e_n} </math> where the <math>\displaystyle p_i </math> are primes.  Now, we can use a [[PIE]] argument to count the number of numbers less than or equal to  <math> n </math> are are relatively prime to it.
To derive the formula, let us first define the prime factorization of <math> n </math> as <math> n = p_1^{e_1}p_2^{e_2}\cdot p_n^{e_n} </math> where the <math>\displaystyle p_i </math> are primes.  Now, we can use a [[PIE]] argument to count the number of numbers less than or equal to  <math> n </math> that are relatively prime to it.


First, let's count the complement of what we want (i.e. all the numbers less than <math> n </math> that share a common factor with it).  There are <math> p_1^{e_1-1}p_2^{e_2}\cdots p_n^{e_n} </math> numbers less than <math> n </math> that are divisible by <math> p_1 </math>.  If we do the same for each <math> p_k </math> and add these up, we get  
First, let's count the complement of what we want (i.e. all the numbers less than <math> n </math> that share a common factor with it).  There are <math> p_1^{e_1-1}p_2^{e_2}\cdots p_n^{e_n} </math> numbers less than <math> n </math> that are divisible by <math> p_1 </math>.  If we do the same for each <math> p_k </math> and add these up, we get  
Line 8: Line 8:
<center><math> p_1{e_1-1}p_2^{e_2}\cdots p_n{e_n} + p_1^{e_1}p_2^{e_2-1}\cdots p_n^{e_n} + \cdots + p_1^{e_1}p_2^{e_2}\cdots p_n^{e_n - 1}.</math></center>
<center><math> p_1{e_1-1}p_2^{e_2}\cdots p_n{e_n} + p_1^{e_1}p_2^{e_2-1}\cdots p_n^{e_n} + \cdots + p_1^{e_1}p_2^{e_2}\cdots p_n^{e_n - 1}.</math></center>


We can factor out though:
We can factor out, though:


<center><math> p_1^{e_1-1}p_2^{e_2-1}\cdots p_n^{e_n-1}(p_1+p_2+\cdots + p_n).</math></center>
<center><math> p_1^{e_1-1}p_2^{e_2-1}\cdots p_n^{e_n-1}(p_1+p_2+\cdots + p_n).</math></center>


But we are obviously overcounting.  So we then subtract out those divisible by two of the <math> p_1 </math>.  We continue with this PIE argument to figure out that the number of elements in the complement of what we want is
But we are obviously overcounting.  We then subtract out those divisible by two of the <math> p_1 </math>.  We continue with this PIE argument to figure out that the number of elements in the complement of what we want is


<center><math>p_1^{e_1-1}p_2^{e_2-1}\cdots p_n^{e_n-1}[(p_1+p_2+\cdots+p_n)-(p_1p_2+p_1p_3+\cdots+(-1)^np_{n-1}p_n)+\cdots+p_1p_2\cdots p_n]</math></center>
<center><math>p_1^{e_1-1}p_2^{e_2-1}\cdots p_n^{e_n-1}[(p_1+p_2+\cdots+p_n)-(p_1p_2+p_1p_3+\cdots+(-1)^np_{n-1}p_n)+\cdots+p_1p_2\cdots p_n]</math></center>

Revision as of 11:49, 26 June 2006

Euler's totient function, $\displaystyle \phi(n)$, is defined as the number of positive integers less than or equal to a given positive integer that is relatively prime to that integer. $\displaystyle \phi(n)$ is read "phi of n."

Formulas

To derive the formula, let us first define the prime factorization of $n$ as $n = p_1^{e_1}p_2^{e_2}\cdot p_n^{e_n}$ where the $\displaystyle p_i$ are primes. Now, we can use a PIE argument to count the number of numbers less than or equal to $n$ that are relatively prime to it.

First, let's count the complement of what we want (i.e. all the numbers less than $n$ that share a common factor with it). There are $p_1^{e_1-1}p_2^{e_2}\cdots p_n^{e_n}$ numbers less than $n$ that are divisible by $p_1$. If we do the same for each $p_k$ and add these up, we get

$p_1{e_1-1}p_2^{e_2}\cdots p_n{e_n} + p_1^{e_1}p_2^{e_2-1}\cdots p_n^{e_n} + \cdots + p_1^{e_1}p_2^{e_2}\cdots p_n^{e_n - 1}.$

We can factor out, though:

$p_1^{e_1-1}p_2^{e_2-1}\cdots p_n^{e_n-1}(p_1+p_2+\cdots + p_n).$

But we are obviously overcounting. We then subtract out those divisible by two of the $p_1$. We continue with this PIE argument to figure out that the number of elements in the complement of what we want is

$p_1^{e_1-1}p_2^{e_2-1}\cdots p_n^{e_n-1}[(p_1+p_2+\cdots+p_n)-(p_1p_2+p_1p_3+\cdots+(-1)^np_{n-1}p_n)+\cdots+p_1p_2\cdots p_n]$

which we can factor further as

$p_1^{e_1-1}p_2^{e_2-1}\cdots p_n^{e_n-1}(p_1-1)(p_2-1)\cdots(p_n-1).$

Making one small adjustment, we write this as

$\phi(n) = n\left(1-\frac 1{p_1}\right)\left(1-\frac 1{p_2}\right)\cdots\left(1-\frac 1{p_n}\right).$

Given the general prime factorization of ${n} = {p}_1^{e_1}{p}_2^{e_2} \cdots {p}_m^{e_m}$, one can compute $\phi(n)$ using the formula $\phi(n) = n\left(1-\frac{1}{p_1}\right)\left(1-\frac{1}{p_2}\right) \cdots \left(1-\frac{1}{p_m}\right)$.

Identities

For prime p, $\phi(p)=p-1$, because all numbers less than ${p}$ are relatively prime to it.

For relatively prime ${a}, {b}$, $\phi{(a)}\phi{(b)} = \phi{(ab)}$.

In fact, we also have for any ${a}, {b}$ that $\phi{(a)}\phi{(b)}\gcd(a,b)=\phi{(ab)}\phi({\gcd(a,b)})$.

For any $n$, we have $\sum_{d|n}\phi(d)=n$ where the sum is taken over all divisors d of $n$.

See also