欧拉函数
-
p p p是素数,则有 ϕ ( p ) = p − 1 \phi(p) = p - 1 ϕ(p)=p−1
证明:显然。
-
p p p是素数, n = p k n = p ^ k n=pk,则 ϕ ( n ) = p k − p k − 1 \phi(n) = p ^ k - p ^ {k - 1} ϕ(n)=pk−pk−1
证明:
[ 1 , n ] [1, n] [1,n]内, p p p的约数有 p , 2 p , 3 p , 4 p … … ( p k − 1 − 1 ) p p, 2p, 3p, 4p……(p^{k - 1} - 1)p p,2p,3p,4p……(pk−1−1)p个,所以 ϕ ( n ) = p k − 1 − ( p k − 1 − 1 ) = p k − p k − 1 \phi(n) = p^k - 1 - (p ^ {k - 1} - 1) = p ^ k - p ^ {k - 1} ϕ(n)=pk−1−(pk−1−1)=pk−pk−1
-
p , q p, q p,q是素数, ϕ ( p q ) = ϕ ( p ) ∗ ϕ ( q ) \phi(pq) = \phi(p) * \phi(q) ϕ(pq)=ϕ(p)∗ϕ(q)
证明:
p q − 1 pq - 1 pq−1内是 p p p的倍数的有 q − 1 q - 1 q−1个,是 q q q的倍数的有 p − 1 p - 1 p−1个, ϕ ( p q ) = p q − 1 − ( q − 1 ) − ( p − 1 ) = p q − p − q − 1 = ( p − 1 ) ( q − 1 ) = ϕ ( p ) ϕ ( q ) \phi(pq) = pq - 1 - (q - 1) - (p - 1) = pq - p - q - 1 = (p - 1)(q - 1) = \phi(p)\phi(q) ϕ(pq)=pq−1−(q−1)−(p−1)=pq−p−q−1=(p−1)(q−1)=ϕ(p)ϕ(q)
拓展 p , q p, q p,q互质即可满足条件。
-
a % p = = 0 , p 是 质 数 a \% p == 0, p是质数 a%p==0,p是质数,则 ϕ ( a p ) = ϕ ( a ) p \phi(ap) = \phi(a)p ϕ(ap)=ϕ(a)p
证明:
一定有 a = k p n a = kp^n a=kpn, k , p k, p k,p互质,
∴ ϕ ( a ) = ϕ ( k ) ϕ ( p n ) \therefore \phi(a) = \phi(k)\phi(p^n) ∴ϕ(a)=ϕ(k)ϕ(pn)
∴ ϕ ( k ) = ϕ ( a ) ϕ ( a n ) \therefore\phi(k) = \frac{\phi(a)}{\phi(a^n)} ∴ϕ(k)=ϕ(an)ϕ(a)
∵ a p = k p n + 1 \because ap = k p ^{n + 1} ∵ap=kpn+1
∴ ϕ ( a p ) = ϕ ( k ) ϕ ( p n + 1 ) \therefore\phi(ap) = \phi(k)\phi(p ^{n + 1}) ∴ϕ(ap)=ϕ(k)ϕ(pn+1)
∴ ϕ ( a p ) = ϕ ( a ) ϕ ( p n + 1 ) ϕ ( p n ) \therefore\phi(ap) = \phi(a) \frac{\phi(p ^{n + 1})}{\phi(p ^n)} ∴ϕ(ap)=ϕ(a)ϕ(pn)ϕ(pn+1)
∵ ϕ ( p n + 1 ) = p n + 1 − p n , ϕ ( p n ) = p n − p n − 1 \because \phi(p ^{n + 1}) = p ^{n + 1} - p ^ n, \phi(p ^n) = p ^ n - p ^{n - 1} ∵ϕ(pn+1)=pn+1−pn,ϕ(pn)=pn−pn−1
∴ ϕ ( a p ) = ϕ ( a ) ϕ ( p n + 1 ) ϕ ( p n ) = ϕ ( a ) p n + 1 − p n p n − p n − 1 \therefore\phi(ap) = \phi(a) \frac{\phi(p ^ {n + 1})}{\phi(p ^ n)} = \phi(a) \frac{p ^ {n + 1} - p ^ n}{p ^n - p ^ {n - 1}} ∴ϕ(ap)=ϕ(a)ϕ(pn)ϕ(pn+1)=ϕ(a)pn−pn−1pn+1−pn
∴ ϕ ( a p ) = ϕ ( a ) p \therefore \phi(ap) = \phi(a)p ∴ϕ(ap)=ϕ(a)p
-
n = p 1 a 1 p 2 a 2 … … p n a n n = p_1 ^ {a_1}p_2 ^ {a_2}……p_n ^{a_n} n=p1a1p2a2……pnan则, ϕ ( n ) = n ( 1 − 1 p 1 ) ( 1 − 1 p 2 ) … … 1 p n \phi(n) = n(1 - \frac{1}{p_1})(1 - \frac{1}{p_2})……\frac{1}{p_n} ϕ(n)=n(1−p11)(1−p21)……pn1
证明:
∵ ϕ ( n ) = ϕ ( p 1 a 1 ) ϕ ( p 2 a 2 ) … … ϕ ( p n a n ) \because\phi(n) = \phi(p_1^{a_1})\phi(p_2^{a_2})……\phi(p_n^{a_n}) ∵ϕ(n)=ϕ(p1a1)ϕ(p2a2)……ϕ(pnan)
∴ ϕ ( n ) = ( p 1 a 1 − p 1 a 1 − 1 ) ( p 2 a 2 − p 2 a 2 − 1 ) … … ( p n a n − p n a n − 1 ) \therefore\phi(n) = (p_1^{a_1} - p_1^{a_1 - 1})(p_2^{a_2} - p_2 ^{a_2 - 1})……(p_n ^{a_n} - p_n^{a_n - 1}) ∴ϕ(n)=(p1a1−p1a1−1)(p2a2−p2a2−1)……(pnan−pnan−1)
每个括号里提出一个 p i a i p_i ^{a_i} piai得 ϕ ( n ) = p 1 a 1 p 2 a 2 … … p n a n ( 1 − 1 p 1 ) ( 1 − 1 p 2 ) … … 1 p n \phi(n) = p_1 ^ {a_1}p_2 ^ {a_2}……p_n ^{a_n}(1 - \frac{1}{p_1})(1 - \frac{1}{p_2})……\frac{1}{p_n} ϕ(n)=p1a1p2a2……pnan(1−p11)(1−p21)……pn1
即证得: ϕ ( n ) = n ( 1 − 1 p 1 ) ( 1 − 1 p 2 ) … … 1 p n \phi(n) = n(1 - \frac{1}{p_1})(1 - \frac{1}{p_2})……\frac{1}{p_n} ϕ(n)=n(1−p11)(1−p21)……pn1
-
关于欧拉函数得递推求法
显然可以在欧拉素数筛的同时得到欧拉函数值
p r i m e [ j ] ∣ i prime[j] \mid i prime[j]∣i时,有 ϕ ( i ∗ p r i m e [ j ] ) = ϕ ( i ) ∗ p r i m e [ j ] \phi(i * prime[j]) = \phi(i) * prime[j] ϕ(i∗prime[j])=ϕ(i)∗prime[j]
其次就是两个互质的情况了
ϕ ( i ∗ p r i m e [ j ] ) = ϕ ( i ) ∗ ( p r i m e [ j ] − 1 ) \phi(i * prime[j]) = \phi(i) * (prime[j] - 1) ϕ(i∗prime[j])=ϕ(i)∗(prime[j]−1)
再最后就是 i i i为质数的情况了, ϕ ( i ) = i − 1 \phi(i) = i - 1 ϕ(i)=i−1
-
n n n的所有约数的欧拉函数之和等于 n n n
证明:
-
对于给定 n n n, ∑ i = 1 n − 1 i ( g c d ( i , n ) = = 1 ) = n ϕ n 2 \sum_{i = 1}^{n - 1}i(gcd(i, n) == 1) = \frac{n\phi{n}}{2} ∑i=1n−1i(gcd(i,n)==1)=2nϕn
证明:
显然 g c d ( i , n ) = 1 gcd(i, n) = 1 gcd(i,n)=1,则有 g c d ( n − i , n ) = 1 gcd(n - i, n) = 1 gcd(n−i,n)=1,所以互质数两两存在则有上面式子 ∑ i = 1 n − 1 i ( g c d ( i , n ) = = 1 ) = n ϕ n 2 \sum_{i = 1}^{n - 1}i(gcd(i, n) == 1) = \frac{n\phi{n}}{2} ∑i=1n−1i(gcd(i,n)==1)=2nϕn成立。
-
d = g c d ( a , b ) d = gcd(a, b) d=gcd(a,b), ϕ ( a b ) = ϕ ( a ) ϕ ( b ) d ϕ ( d ) \phi(ab) = \frac{\phi(a)\phi(b)d}{\phi(d)} ϕ(ab)=ϕ(d)ϕ(a)ϕ(b)d
证明: