This article is purely original. content source: Peking University's video teaching ..
It is really not easy to understand the proof of this theorem. After understanding this theorem, I personally think that the Euler function is really not difficult...
Theorem: If m and n are twoMutual QualityThe integers x and y simplify the remainder system by Modulo M and N respectively, then n * x + M * y simplifies the remainder system by M * n.
Alternative Syntax: x = {x1, x2, X3, x4..... xe (m)} Is mod m to simplify the remaining Series
Y = {y1, Y2, Y3, y4...... xe (n)} Is mod n to simplify the residual system.
Now we need to prove that M * Yi + N * XJ {I = 1, 2, 3, 4 .. E (m); j = 1, 2, 3 ,... E (n)} is a simplified remainder of N * m
Proof: 1: interconnectivity with N * m
2: Different Remainder
3: The simplified remainder of N * m can be written as M * Yi + N * XJ {I = 1, 2, 3, 4 .. E (m); j = 1, 2, 3 ,... E (n)} format
Proof 1: Because (m, n) = 1; {x1, x2, X3, x4...... xe (m)} Is mod m to simplify the residual system,
==> (M, XJ) = 1 ;=>(M, n * XJ) = 1;==>
Available with Division(A, B) = (a, B + A * r)==>(M, M * Yi + N * XJ) = 1; (1)
Because (m, n) = 1; (n, Yi) = 1; =>(N, m * Yi) = 1 ;=> (n, m * Yi + N * XJ) = 1; (2)
By (1) (2)(M * n, m * Yi + N * XJ) = 1;
Proof 2: Assuming that M * Yi + N * XJ and M * Yu + N * XV are mod m * n same, it is necessary to prove that YI = Yu and XJ = XV;
Because they are the sameM * n | M * (Yi-yu) + N * (XJ-XV );
BecauseM | M * n, n | N * m==> M | M * (Yi-yu) + N * (XJ-xv); ==> M | N * (XJ-XV ); ==> M | (XJ-XV );
==> N | M * (Yi-yu) + N * (XJ-xv); ==> n | M * (Yi-yu ); ==> n | (Yi-yu );
And because X = {x1, x2, X3, x4...... xe (m)} Is mod m, which simplifies the residual System
Y = {y1, Y2, Y3, y4...... xe (n)} Is mod n to simplify the residual system.
XJ-XV mod m remainder must be smaller than m
Yi-yu mod n remainder must be less than N
So YI = Yu, XJ = XV;
Proof 3: any integer a (0 <= A <= m * n-1), (m, n) = 1;
It exists S * m + n * T = 1;Both sides multiply by a at the same timeA * S * m + A * n * t =;
If y = S * a, x = A * t; then:M * Y + N * x =;
Now it is proved that any number of mutual qualities a and M * n is (M * n, a) = 1; (3)
If (n, y) = 1 and (m, x) = 1 (where x, y must be above X, Y to simplify the data in the remaining series );
Then the value of M * n must be written in the form of M * Yi + N * XJ.
That proves (3) (M * n, m * Y + N * X) = 1 ;=> (M, M * Y + N * X) = 1 ;=> (m, N * X) = 1; => (M, x) = 1;
==> (N, m * Y + N * X) = 1 ;=> (n, m * y) = 1 ;=> (n, Y) = 1;
Certificate complete !!
Now let's take a look: the simplified remainder of N * m is M * Yi + N * XJ.
M * Y1 + N * X1, M * y2 + N * X1, M * Y3 + N * x1 ............... M * Ye (n) + x1;
M * Y1 + N * X2 ,................................ ..........
M * Y1 + N * X3 ,................................ ......
M * Y1 + N * X4 ,................................ .....
........................................ ........
........................................ ....
M * Y1 + N * xe (m ).............................. M * Ye (n) + N * xe (m );
So it is easy to see that E (n * m) = E (n) * E (m); the premise is (m, n) = 1;
So we get this very important inference...
Euler's function formulas:
SetA = p1 ^ A1 * P2 ^ A2 * P3 ^ A3 *... * PK ^ AK;
ThenE (A) = A * (1-1/P1) * (1-1/P2) *... * (1-1/PK );
Formula calculation will not be done, because Euler's function is a product function, just use inferences to push it...
To translate into code: So the formula variant:E (A) = (p1-1) * P1 ^ (a1-1) * (p2-1) * P2 ^ (a2-1 )*........ * (pk-1) * PK ^ (ak-1 );
I wrote ugly code myself. Don't try it ..!!
# Include <iostream>
# Include <cmath>
Using namespace STD;
Int Euler (int n ){
Int sum = 1;
For (INT I = 2; I * I <= N; I ++ ){
Int A = 0;
If (N % I = 0 ){
While (N % I = 0 ){
N/= I;
A ++;
}
}
If (){
Sum = sum * (I-1) * (INT) Pow (I * 1.0, A-1 );
}
}
If (n> 1) sum * = (n-1); // considering that the last number may be a prime number, you must add
Return sum;
}
Int main (){
Int N;
While (CIN> N, N ){
Int sum = 0;
Sum = Euler (N );
Cout <sum <Endl;
}
}