The mathematician Leonhard Euler defined the function by the
rule
= the number of mod x standard names that are
relatively prime to x.
In this class, we use two formulas for .
If m is a prime number then . This formula holds
because every number from 0 to m-1 is relatively prime to m except
0.
If m is the product of two distinct primes p and q then
This formula holds because every number from 0 to m-1 is relatively prime to m except the following numbers.
and
There are q-1 in the first list and p-1 in the second list, for a total of (q-1)+(p-1), except that 0 appeared in both list, so the real total is (q-1)+(p-1)-1. Thus the number of numbers from 0 to m-1 that are relatively prime is the total number of numbers from 0 to m-1, namely m, minus the number that are not relatively prime, namely (q-1)+(p-1)-1. Replacing m by pq, we get
Note that , which is the same as
pq-((q-1)+(p-1)-1). Thus
.
When p and q are small numbers, is noticeably smaller
than pq. For example,
is
, which is 2.
Another example:
. However, when p and q get really
big, pq is enormous, so the difference between pq and
pq-((q-1)+(p-1)-1) is really not so significant. For example,
say p=9871 and q=9533. Then pq=94100243 and
. If you picked a random number between 0 and
pq-1, it would most likely be relatively prime to pq.