# Difference between revisions of "Euler's totient function"

m (correct category) |
(→Formulas: fixed the proof) |
||

Line 4: | Line 4: | ||

To derive the formula, let us first define the [[prime factorization]] of <math> n </math> as <math> n =\prod_{i=1}^{m}p_i^{e_i} =p_1^{e_1}p_2^{e_2}\cdots p_m^{e_m} </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. | To derive the formula, let us first define the [[prime factorization]] of <math> n </math> as <math> n =\prod_{i=1}^{m}p_i^{e_i} =p_1^{e_1}p_2^{e_2}\cdots p_m^{e_m} </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> | + | 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> \frac{n}{p_1} </math> numbers less than <math> n </math> that are divisible by <math> p_1 </math>. If we do the same for each <math> p_i </math> and add these up, we get |

− | < | + | <cmath> \frac{n}{p_1} + \frac{n}{p_2} + \cdots + \frac{n}{p_m} = \sum^m_{i=1}\frac{n}{p_i}.</cmath> |

− | We | + | But we are obviously overcounting. We then subtract out those divisible by two of the <math> p_i </math>. There are <math>\sum_{1 \le i_1 < i_2 \le m}\frac{n}{p_{i_1}p_{i_2}}</math> such numbers. We continue with this PIE argument to figure out that the number of elements in the complement of what we want is |

− | + | \[ \sum_{1 \le i \le m}\frac{n}{p_i} | |

+ | - \sum_{1 \le i_1 < i_2 \le m}\frac{n}{p_{i_1}p_{i_2}} | ||

+ | + \cdots + (-1)^{m+1}\frac{n}{p_1p_2\ldots p_m}.\] | ||

− | + | This sum represents the number of numbers less than <math>n</math> sharing a common factor with <math>n</math>, so | |

+ | \[\begin{align*} | ||

+ | \phi(n) &= n - (\sum_{1 \le i \le m}\frac{n}{p_i} | ||

+ | - \sum_{1 \le i_1 < i_2 \le m}\frac{n}{p_{i_1}p_{i_2}} | ||

+ | + \cdots + (-1)^{m+1}\frac{n}{p_1p_2\ldots p_m})\\ | ||

+ | &= n(1 - \sum_{1 \le i \le m}\frac{1}{p_i} | ||

+ | + \sum_{1 \le i_1 < i_2 \le m}\frac{1}{p_{i_1}p_{i_2}} | ||

+ | - \cdots + (-1)^{m}\frac{1}{p_1p_2\ldots p_m})\\ | ||

+ | &= n(1-\frac{1}{p_1})(1-\frac{1}{p_2})\cdots(1-\frac{1}{p_m}). | ||

+ | \end{align*}\] | ||

− | + | 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(1-\frac{1}{p_1})(1-\frac{1}{p_2}) \cdots (1-\frac{1}{p_m}).</cmath> | |

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | |||

− | 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 | ||

== Identities == | == Identities == |

## Revision as of 23:56, 27 January 2009

**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."

## Contents

## 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

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

\[ \sum_{1 \le i \le m}\frac{n}{p_i} - \sum_{1 \le i_1 < i_2 \le m}\frac{n}{p_{i_1}p_{i_2}} + \cdots + (-1)^{m+1}\frac{n}{p_1p_2\ldots p_m}.\]

This sum represents the number of numbers less than sharing a common factor with , so \[\begin{align*} \phi(n) &= n - (\sum_{1 \le i \le m}\frac{n}{p_i} - \sum_{1 \le i_1 < i_2 \le m}\frac{n}{p_{i_1}p_{i_2}} + \cdots + (-1)^{m+1}\frac{n}{p_1p_2\ldots p_m})\\ &= n(1 - \sum_{1 \le i \le m}\frac{1}{p_i} + \sum_{1 \le i_1 < i_2 \le m}\frac{1}{p_{i_1}p_{i_2}} - \cdots + (-1)^{m}\frac{1}{p_1p_2\ldots p_m})\\ &= n(1-\frac{1}{p_1})(1-\frac{1}{p_2})\cdots(1-\frac{1}{p_m}). \end{align*}\]

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 .

Proof. Split the set into disjoint sets where for all we have Now if and only if . Furthermore, if and only if . Now one can see that the number of elements of equals the number of elements of Thus by the definition of Euler's phi we have that . As every integer which satisfies belongs in exactly one of the sets , we have that

## Notation

Sometimes, instead of , is used. This variation of the Greek letter *phi* is common in textbooks, and is standard usage on the English Wikipedia