OFFSET
0,3
LINKS
Index entries for linear recurrences with constant coefficients, signature (1,0,2,-2,0,-1,1).
FORMULA
a(3*k) = (k+1)^2 - 1 = A005563(k+1);
a(3*k+1) = (k+1)^2 = A000290(k+1);
a(3*k+2) = (k+1)^2 + 1 = A002522(k+1).
a(n) = floor(n/3)*(floor(n/3) + 2) + n mod 3.
G.f.: -x*(1+x)*(x^4-2*x^3+x^2+1) / ( (1+x+x^2)^2*(x-1)^3 ). - R. J. Mathar, May 22 2019
From Amiram Eldar, Sep 14 2022: (Start)
Sum_{n>=1} 1/a(n) = coth(Pi)*Pi/2 + Pi^2/6 + 1/4.
Sum_{n>=1} (-1)^(n+1)/a(n) = cosech(Pi)*Pi/2 + Pi^2/12 - 1/4. (End)
MATHEMATICA
dnsQ[n_]:=Module[{x=Floor[Sqrt[n]]}, Min[n-x^2, (x+1)^2-n]<=1]; Select[Range[0, 450], dnsQ] (* Harvey P. Dale, May 25 2011 *)
Table[n^2+{-1, 0, 1}, {n, 20}]//Flatten (* Harvey P. Dale, Jan 17 2022 *)
PROG
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Reinhard Zumkeller, Aug 28 2003
STATUS
approved