OFFSET
0,4
LINKS
Robert Israel, Table of n, a(n) for n = 0..10000
FORMULA
From Robert Israel, Dec 27 2018: (Start)
a(n) = n(n+1)/2 - m(m+1)(m+2)/3 where m = floor(sqrt(n)).
G.f.: x/(1-x)^3 - (1-x)^(-1)*Sum_{k>=1} (k^2+k)*x^(k^2). (End)
EXAMPLE
0-1=-1,-1+2=1,1+3=4,4-sqrt(4) = 2
MAPLE
f:= proc(n) local m; m:= floor(sqrt(n));
n*(n+1)/2-m*(m+1)*(m+2)/3
end proc:
map(f, [$0..100]); # Robert Israel, Dec 27 2018
MATHEMATICA
f[n_] := If[IntegerQ[Sqrt[n]], -Sqrt[n], n];
f /@ Range[0, 100] // Accumulate (* Jean-François Alcover, Aug 26 2020 *)
PROG
(PARI) g(n) = my(s=0); for(x=0, n, if(issquare(x), s-=sqrtint(x), s+=x); print1(s, ", "))
CROSSREFS
KEYWORD
easy,sign
AUTHOR
Cino Hilliard, Jun 13 2005
STATUS
approved