Difference between revisions of "Euler's totient function"
m (→Formulas) |
|||
Line 2: | Line 2: | ||
== 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}\ | + | To derive the formula, let us first define the [[prime factorization]] of <math> n </math> as <math> n =\prod_{i=1}^{n}p_i^{e_i} =p_1^{e_1}p_2^{e_2}\cdots p_n^{e_n} </math> where the <math>p_i </math> are distinct [[prime number]]s. 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 12: | Line 12: | ||
<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. We then subtract out those divisible by two of the <math> | + | But we are obviously overcounting. We then subtract out those divisible by two of the <math> p_k </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+ | + | <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+p_{n-1}p_n)+\cdots+(-1)^{n+1}(p_1p_2\cdots p_n)]</math></center> |
which we can factor further as | which we can factor further as | ||
Line 24: | Line 24: | ||
<center><math> \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).</math></center> | <center><math> \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).</math></center> | ||
− | Given the general [[prime factorization]] of <math>{n} = {p}_1^{e_1}{p}_2^{e_2} \cdots {p}_m^{e_m}</math>, one can compute <math>\phi(n)</math> using the formula < | + | Given the general [[prime factorization]] of <math>{n} = {p}_1^{e_1}{p}_2^{e_2} \cdots {p}_m^{e_m}</math>, one can compute <math>\phi(n)</math> using the formula <cmath>\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)</cmath> |
== Identities == | == Identities == |
Revision as of 10:25, 8 November 2007
Euler's totient function applied to a positive integer
is defined to be the number of positive integers less than or equal to
that are relatively prime to
.
is read "phi of n."
Formulas
To derive the formula, let us first define the prime factorization of as
where the
are distinct prime numbers. Now, we can use a PIE argument to count the number of numbers less than or equal to
that are relatively prime to it.
First, let's count the complement of what we want (i.e. all the numbers less than that share a common factor with it). There are
numbers less than
that are divisible by
. If we do the same for each
and add these up, we get

We can factor out, though:

But we are obviously overcounting. We then subtract out those divisible by two of the . 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+p_{n-1}p_n)+\cdots+(-1)^{n+1}(p_1p_2\cdots p_n)]$](http://latex.artofproblemsolving.com/b/c/a/bca154e56dd5c5f497ea999bbc37d8f1839925ab.png)
which we can factor further as

Making one small adjustment, we write this as

Given the general prime factorization of , one can compute
using the formula
Identities
For prime p, , because all numbers less than
are relatively prime to it.
For relatively prime ,
.
In fact, we also have for any that
.
For any , we have
where the sum is taken over all divisors d of
.