Given a number \$n\$, Euler's totient function, \$\varphi(n)\$ is the number of integers up to \$n\$ which are coprime to \$n\$. That is, no number bigger than \$1\$ divides both of them. For example, \$\varphi(6) = 2\$, because the only relevant numbers are \$1, 5\$. This is OEIS A000010.
We can now define the sum of euler's totient function as \$S(n) = \sum_{i=1}^{n}{\varphi(i)}\$, the sum of \$\varphi(i)\$ for all numbers from \$1\$ to \$n\$. This is OEIS A002088.
Your task is to calculate \$S(n)\$, in time sublinear in \$\mathbf{n}\$, \$o(n)\$.
Test cases
10 -> 32
100 -> 3044
123 -> 4636
625 -> 118984
1000 -> 304192
1000000 (10^6) -> 303963552392
1000000000 (10^9) -> 303963551173008414
Rules
- Your complexity must be \$o(n)\$. That is, if your algorithm takes time \$T(n)\$ for input \$n\$, you must have \$\lim_{n\to\infty}\frac{T(n)}n = 0\$. Examples of valid time complexities are \$O(\frac n{\log(n)})\$, \$O(\sqrt n)\$, \$O(n^\frac57 \log^4(n))\$, etc.
- You can use any reasonable I/O format.
- Note that due to the limited complexity you can't take the input in unary nor output in it (because then the I/O takes \$\Omega(n)\$ time), and the challenge might be impossible in some languages.
- Your algorithm should in theory be correct for all inputs, but it's fine if it fails for some of the big test cases (due to overflow or floating-point inaccuracies, for example).
- Standard loopholes are disallowed.
This is code golf, so the shortest answer in each language wins.