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