login
A309081
a(n) = n - floor(n/2^2) + floor(n/3^2) - floor(n/4^2) + ...
4
1, 2, 3, 3, 4, 5, 6, 6, 8, 9, 10, 10, 11, 12, 13, 12, 13, 15, 16, 16, 17, 18, 19, 19, 21, 22, 24, 24, 25, 26, 27, 26, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 37, 38, 39, 38, 40, 42, 43, 43, 44, 46, 47, 47, 48, 49, 50, 50, 51, 52, 54, 52, 53, 54, 55, 55, 56, 57, 58, 58, 59, 60, 62
OFFSET
1,2
LINKS
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