OFFSET
1,1
LINKS
Seiichi Manyama, Table of n, a(n) for n = 1..10000
J. Lehner and M. Newman, Sums involving Farey fractions, Acta Arithmetica 15.2 (1969): 181-187. See Eq. (19).
FORMULA
G.f.: (1/(1 - x)) * (-x + 3 * Sum_{k>=1} mu(k) * x^k / (1 - x^k)^2). - Ilya Gutkovskiy, Feb 14 2020
MAPLE
with(numtheory);
f:=n->3*add(phi(r), r=1..n)-1;
[seq(f(r), r=1..50)];
MATHEMATICA
Table[3 Sum[EulerPhi@ k, {k, n}] - 1, {n, 57}] (* Michael De Vlieger, Dec 16 2016 *)
PROG
(Python)
from functools import lru_cache
@lru_cache(maxsize=None)
if n == 0:
return -1
c, j = 0, 2
k1 = n//j
while k1 > 1:
j2 = n//k1 + 1
c += (j2-j)*(2*A278049(k1)-1)//3
j, k1 = j2, n//j2
return 3*(n*(n-1)-c+j)//2 - 1 # Chai Wah Wu, Mar 25 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Nov 22 2016
STATUS
approved