Euler's Function
In number theory, for a positive integer N, the Euler's function is the number of numbers that are less than or equal to the number of numbers that intersect with N. This function is named by Euler, the first investigator. It is also known as Euler's totient function, Phi function, and Euler's business number. For example, Phi (8) = 4, because 1, 3, 5, 7 and 8 are mutually qualitative. The fact of the ring theory derived from the Euler's function and the Laplace Theorem constitute the proof of the Euler's theorem.
Introduction
The UDF value.
(1) = 1 (the number of unique and 1 mutual quality is 1 itself ).
If n is the k power of prime number P, Phi (n) = P ^ K-P ^ (k-1) = (PM) P ^ (k-1 ), except for the multiples of P, all other numbers are in the same quality as N.
Euler's function is a product function-if M, N are mutually qualitative, Phi (Mn) = PHI (m) PHI (n ).
Special Properties: WHEN n is an odd number, Phi (2n) = PHI (n) proves to be similar.
Proof
Let A, B, and C be a set of numbers with M, N, and Mn. According to the Chinese Remainder Theorem, A * B and C can establish a one-to-one correspondence relationship. Therefore, we can use the basic arithmetic theorem to know the value of PHI (n,
If n = Beijing P ^ (α (subscript p ))
Then PHI (n) = round (p-1) P ^ (α (subscript P)-1) = n round (1-1/p)
For example, Phi (72) = PHI (2 ^ 3 × 3 ^ 2) = (2-1) 2 ^ (3-1) × (3-1) 3 ^ (2-1) = 24
Relationship with Euler's theorem and ferma's Theorem
For any two positive integers a, m, m> = 2
A ^ PHI (m) limit 1 (mod m)
Euler's Theorem
When M is a prime number P, this formula is:
A ^ (p-1) 1_1 (mod P)
That is, ferma's theorem.
Programming of Euler's functions
The Euler's function is used to calculate the Euler's function values of all numbers in a certain range by means of screening.
The Relationship Between Euler's function and its own different prime factors: Euler's function σ (n) = n {p | n} (1-1/p ). (P is the prime factor of number N)
For example:
PSI (10) = 10 × (1-1/2) × (1-1/5) = 4;
PSI (30) = 30 × (1-1/2) × (1-1/3) × (1-1/5) = 8;
PSI (49) = 49 × (1-1/7) = 42.
Detailed reasoning
Euler's function is a very important function in number theory, Euler's Function It refers to the number of positive integers (including 1) with a positive integer N, less than N, and interlace with N ).
Defines a set of numbers less than N and with N mutual quality as Zn, called this set as N Complete remainder set . Apparently | Zn | = PHI (n ).
Related Nature:
For prime numbers P, Phi (p) = p-1.
For two different prime numbers, p and q, their product N = p * Q satisfies the requirements of PHI (n) = (p-1) * (Q-1 ).
This is because ZN = {1, 2, 3 ,..., n-1}-{P, 2 p ,..., (Q-1) * p}-{q, 2q ,..., (P-1) * Q}, then PHI (n) = (n-1)-(q-1)-(p-1) = (p-1) * (Q-1) = PHI (p) * PHI (q ).
Euler's Theorem :
For positive integers A and N of the mutual qualityA Phi (N) Bytes 1 mod n .
Proof:
(1) Order ZN = {x1, x2 ,..., x phi (n)}, S = {A * X1 mod N, A * X2 mod N ,..., A * x PHI (n) mod n },
Then ZN = S.
(1) because of the mutual quality of A and N, XI (1 ≤ I ≤ PHI (N) and N, so a * XI and N ing, so a * Xi mod n ε Zn.
② If I is less than J, then Xi is less than XJ, and a * Xi mod n is less than a * XJ mod n (Elimination Law) can be obtained by a and N mutual quality ).
(2) A Phi (n) * X1 * X2 *... * x PHI (n) mod n
Round (A * X1) * (A * x2) *... * (A * x PHI (N) mod n
Round (A * X1 mod n) * (A * X2 mod n) *... * (A * x PHI (n) mod n
Limit X1 * X2 *... * x PHI (n) mod n
Compare the left and right sides of the equation, because XI (1 ≤ I ≤ PHI (N) and n are of mutual quality, a Phi (n) limit 1 mod n (dealignment Law ).
Note:
Elimination law: If gcd (C, p) = 1, AC hybrid BC mod p contains a Hybrid B mod p.
Ferma Theorem :
If the positive integer a interacts with the prime number P AP-1 Bytes 1 mod p .
This theorem is very simple. It can be proved simply by using the Euler's theorem, because PHI (p) = p-1.
**************************************** *************************************
Supplement: Euler's function formula
(1) Euler's function of PK
For a given prime number P, Phi (p) = p-1. For a positive integer n = PK,
Phi (n) = PK-1
Proof:
The number of positive integers smaller than PK is PK-1, where
Positive Integers that do not interwork with PK{P * 1, p * 2,..., p * (pk-1-1 )}TotalPK-1-1Items
Therefore, Phi (n) = PK-1-(pk-1-1) = PK-1.
(2) Euler's function of p * q
Assume that p and q are two positive integers of mutual quality, then the Euler's function of p * q is
? (P * q) =? (p) *? (q) , Gcd (p, q) = 1 .
Proof:
N = p * q, gcd (p, q) = 1
According to the remainder theorem of China
There is a one-to-one ing between Zn and ZP × ZQ.
Therefore, the number of elements in the complete remainder set of N is equal to the number of ZP x ZQ elements in the set.
The number of elements in the latter is PHI (p) * PHI (q ).
? (P * q) =? (p) *? (q ).
(3) Euler's function of any positive integer
Any integer N can be expressed as the product of its prime factor:
I
N = bytes PIKI(Number of prime factors whose I is N)
I = 1
According to the previous two conclusions, it is easy to conclude that the Euler's function is:
I
Phi (n) = bytes PIKI -1(PI-1) = N records (1-1/ PI)
I = 1 I = 1
For any n> 2,2 | PHI (n), Because it must exist.PI-1Is an even number.
Program Implementation
#include <stdlib.h>#include<stdio.h>#define N 100int main(){ int *phi,i,j; int *prime; prime=(int*)malloc((N+1)*sizeof(int)); prime[0]=prime[1]=0; for(i=2;i<=N;i++) prime[i]=1; for(i=2;i*i<=N;i++) { if(prime[i]) { for(j=i*i;j<=N;j+=i) prime[j]=0; } } //这段求出了N内的所有素数 phi=(int*)malloc((N+1)*sizeof(int)); for(i=1;i<=N;i++) phi[i]=i; for(i=2;i<=N;i++) { if(prime[i]) { for(j=i;j<=N;j+=i) phi[j]=phi[j]/i*(i-1); //此处注意先/i再*(i-1),否则范围较大时会溢出 } } for(i=1;i<N;i++) printf("%d %d\n",i,phi[i]); return 0;}
[Euler's function]