OFFSET
1,2
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
FORMULA
G.f.: (1/(1 - x)) * Sum_{k>=1} (-1)^(k+1) * x^(k^2)/(1 - x^(k^2)).
a(n) ~ Pi^2*n/12. - Vaclav Kotesovec, Oct 12 2019
MAPLE
N:= 100: # for a(1)..a(N)
V:= Vector([$1..N]):
for k from 2 to floor(sqrt(N)) do
for j from 1 to N/k^2 do
t:=min((j+1)*k^2-1, N);
V[j*k^2..t]:= V[j*k^2..t] +~ (-1)^(k+1)*j
od od:
convert(V, list); # Robert Israel, Jul 12 2019
MATHEMATICA
Table[Sum[(-1)^(k + 1) Floor[n/k^2], {k, 1, n}], {n, 1, 75}]
nmax = 75; CoefficientList[Series[1/(1 - x) Sum[(-1)^(k + 1) x^(k^2)/(1 - x^(k^2)), {k, 1, Floor[nmax^(1/2)] + 1}], {x, 0, nmax}], x] // Rest
Table[Sum[Boole[IntegerQ[d^(1/2)] && OddQ[d]], {d, Divisors[n]}] - Sum[Boole[IntegerQ[d^(1/2)] && EvenQ[d]], {d, Divisors[n]}], {n, 1, 75}] // Accumulate
PROG
(Magma) [1] cat [m-&+[(-1)^(k)*Floor(m/k^2):k in [2..m] ]:m in [2..75]]; // Marius A. Burtea, Jul 12 2019
(Python)
from math import isqrt
def A309081(n): return n+sum((1 if k%2 else -1)*(n//k**2) for k in range(2, isqrt(n)+1)) # Chai Wah Wu, Dec 20 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Ilya Gutkovskiy, Jul 11 2019
STATUS
approved