题目:求\(\sum\limits_{i=1}^{n}\gcd(i,n)\)
\(\sum\limits_{i=1}^{n}\gcd(i,n)=\sum_{d\mid n}(d\times\sum\limits_{i=1}^n[\gcd(i,n)==d])=\sum_{d\mid n}(d\times\sum\limits_{i=1}^{\left\lfloor\frac{n}{d}\right\rfloor}[\gcd(di,n)==d])\)
\(=\sum_{d\mid n}d\times\sum\limits_{i=1}^{\left\lfloor\frac{n}{d}\right\rfloor}[\gcd(i,n/d)==1]=\sum_{d\mid n}d\times\varphi(\left\lfloor\frac{n}{d}\right\rfloor)\)