[ exttt{Proposition}
]
定义欧拉函数 (varphi(n)) 为 " 在 (1 sim n) 中与 (n) 互质的数的个数 "。
设 (n) 有 (m) 个质因子 (p_1, ...,p_m),则有 (varphi(n) = n prodlimits_{i=1}^m (1-frac{1}{p_i}))。
[ exttt{Proof}
]
考虑构造 (m) 个集合 (A_1,...,A_m),其中 (A_i = {x in mathbb{Z} | 1 leq x leq n, x mod p_i = 0 })。
显然,在 (1 sim n) 与 (n) 不互质的数的集合为:
[igcuplimits_{i=1}^m A_i
]
故 (varphi(n)) 为:
[n - left| igcuplimits_{i=1}^m A_i
ight|
]
由容斥原理,得:
[n - sumlimits_{1 leq i leq m}left| A_i
ight| + sumlimits_{1 leq i < j leq m} left| A_i igcap A_j
ight| - sumlimits_{1 leq i < j < k leq m} left| A_i igcap A_j igcap A_k
ight| + ... + (-1)^m left| A_1 igcap ... igcap A_m
ight|
]
即:
[n - sumlimits_{1 leq i leq m} frac{n}{p_i} + sumlimits_{1 leq i < j leq m} frac{n}{p_ip_j}- sumlimits_{1 leq i < j < k leq m} frac{n}{p_ip_jp_k} + ... + (-1)^m frac{n}{p_1p_2 ... p_m}
]
提取公因式 (n) 得:
[n imes(1 - sumlimits_{1 leq i leq m} frac{1}{p_i} + sumlimits_{1 leq i < j leq m} frac{1}{p_ip_j}- sumlimits_{1 leq i < j < k leq m} frac{1}{p_ip_jp_k} + ... + (-1)^m frac{1}{p_1p_2 ... p_m})
]
通分,得:
[n imes (frac{p_1p_2 ... p_m}{p_1p_2 ... p_m} - ... + (-1)^{m - 1}sumlimits_{1 leq i leq m} frac{p_i}{p_1p_2 ... p_m} + (-1)^m frac{1}{p_1p_2 ... p_m} )
]
[n imes frac{left( p_1p_2 ... p_m
ight) - ... + (-1)^{m - 1}left( sumlimits_{1 leq i leq m} p_i
ight) + (-1)^m}{p_1p_2 ... p_m}
]
在分子中提取公因式 (p_1),与未包含 (p_1) 的项结合,得:
[n imes frac{left( p_1 - 1
ight)left(- left(p_2 ... p_m
ight) + ... + (-1)^{m - 2}left( sumlimits_{2 leq i leq m} p_i
ight) + left( -1
ight)^{m - 1}
ight)}{p_1p_2 ... p_m}
]
在分子中依次提取 (p2, ...,p_m),得:
[n imes frac{(p_1 - 1)(p_2 - 1) ... (p_m - 1)}{p_1p_2 ... p_m}
]
即:
[n imes frac{p_1 - 1}{p_1} imes frac{p_2 - 1}{p_2} imes ... imes frac{p_m - 1}{p_m}
]
[n prodlimits_{i=1}^m (1-frac{1}{p_i})
]
证毕。