01 - \(\sum\limits_{i=1}^{n} [gcd(i,m)=1]\)
Index: the number n less than the number m coprime
求:\(\sum\limits_{i=1}^{n} [gcd(i,m)=1]\)
- 由 \(\sum\limits_{d|n}\mu(d)=[n=1]\) 得
\(\sum\limits_{i=1}^{n} \sum\limits_{d|gcd(i,m)}\mu(d)\) - Switching sequence summing give
\ (\ sum \ limits_ {d | m} \ mu (d) \ lfloor \ frac {n} {d} \ rfloor \) - When d has a square noted factor \ (\ MU (d) = 0 \) , then obtains \ (m \) all prime factors and inclusion-exclusion (in fact Möbius function itself represents inclusion and exclusion)
- 64-bit integer range prime factors of less than 20 species, inclusion and exclusion complexity does not exceed 1e6 single.
And when n is equal to m, \ (\ varphi (n) = \ SUM \ limits_. 1 = {I} ^ {n} [GCD (I, n) =. 1] \) , for the definition of the Euler function. Can be obtained \ (\ varphi (n) = \ sum \ limits_ {d | n} \ mu (d) \ frac {n} {d} \) i.e. \ (\ frac {\ varphi ( n)} {n} = \ sum \ limits_ {d | n} \ frac {\ mu (d)} {d} \)