0% found this document useful (0 votes)
220 views

Euler Totient Function

The Euler function φ(n) counts the numbers less than n that are relatively prime to n. It has several important properties: 1) If n is prime, then φ(n) = n-1, 2) If n is a power of a prime p, then φ(n) = n(1-1/p), 3) For any two relatively prime numbers m and n, φ(mn) = φ(m)φ(n). The Euler function can be calculated efficiently by factorizing n into prime factors. Euler's theorem states that if φ(n) are relatively prime, then aφ(n) ≡ 1 (mod n).

Uploaded by

gyugam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
220 views

Euler Totient Function

The Euler function φ(n) counts the numbers less than n that are relatively prime to n. It has several important properties: 1) If n is prime, then φ(n) = n-1, 2) If n is a power of a prime p, then φ(n) = n(1-1/p), 3) For any two relatively prime numbers m and n, φ(mn) = φ(m)φ(n). The Euler function can be calculated efficiently by factorizing n into prime factors. Euler's theorem states that if φ(n) are relatively prime, then aφ(n) ≡ 1 (mod n).

Uploaded by

gyugam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Euler function

Definition
Euler function (sometimes denoted or ) - the number of properties to prime to
. In other words, is the amount of numbers in the interval , the greatest common divisor which
with unity.
The first few values of this function ( A000010 in OEIS encyclopedia ):





Properties
The following three simple properties of the Euler - enough to learn how to calculate it for any number:
If - prime, then .
(This is obvious, since any number, except for the relatively easy with him.)
If - simple - natural number, then .
(Because the number of not only relatively prime numbers of the form , which pieces.)

If and are relatively prime, then ("multiplicative" Euler function).
(This follows from the Chinese Remainder Theorem . Consider an arbitrary number .
denote and remainders on and respectively. then coprime if and only if coprime and
individually, or what is the same, mutually simply and coprime . Applying the Chinese remainder
theorem, we see that any pair of numbers and the number of one-to-one correspondence , which completes
the proof.)
We can obtain the Euler function for any through its factorization (decomposition into prime factors):
if

(Where all - simple), then



Implementation
The simplest code calculating the Euler function, factoring in the number of elementary method :
int phi (int n) {
int result = n;
for (int i=2; i*i<=n; ++i)
if (n % i == 0) {
while (n % i == 0)
n /= i;
result -= result / i;
}
if (n > 1)
result -= result / n;
return result;
}
The key place for the calculation of the Euler function - is to find the factorization of the number . It can be
carried out for a time considerably shorter : see Efficient algorithms for factorization .
Applications of the Euler function
The most famous and important property of Euler's function is expressed in Euler's theorem :

where and are relatively prime.
In the particular case when a simple Euler's theorem turns into the so-called Fermat's little theorem :

Euler's theorem often occurs in practical applications, for example, see Reverse item in the mod .
Problem in online judges
Task List, which requires a function to calculate the Euler or use Euler's theorem, either by value of the Euler
function to restore the original number:
UVA # 10179 "Irreducible Basic Fractions" [Difficulty: Easy]
UVA # 10299 "Relatives" [Difficulty: Easy]
UVA # 11327 "Enumerating Rational Numbers" [Difficulty: Medium]
TIMUS # 1673 "Admission to the exam" [difficulty: high]

You might also like