OFFSET
1,2
COMMENTS
Any three consecutive terms sum up to a perfect square. First 9 terms coincide with A076991.
Changing a(1) leaves a(5+3m) constant for m >= 0. Changing a(2) leaves a(4+3m) constant for m >= 0. - Richard R. Forberg, Jun 05 2013
LINKS
Index entries for linear recurrences with constant coefficients, signature (2,-1,1,-2,1).
FORMULA
a(1)=1, a(2)=2; n>2: a(n)=n^2-a(n-1)-a(n-2).
G.f.: x*(1+3*x^2-3*x^3+x^4)/(1+x+x^2)/(1-x)^3. - Maksym Voznyy (voznyy(AT)mail.ru), Jul 27 2009; checked and corrected by R. J. Mathar, Sep 16 2009
a(n) = floor((n^2+2*n+1)/3) + 1 - (n mod 3). - Ivan Neretin, May 25 2015
For n>6, a(n)=2*a(n-3)-a(n-6)+6. - Zak Seidov, Aug 05 2016
EXAMPLE
1+2+6=3^2, 2+6+8=4^2, 6+8+11=5^2.
G.f. = x + 2*x^2 + 6*x^3 + 8*x^4 + 11*x^5 + 17*x^6 + 21*x^7 + 26*x^8 + ...
MAPLE
A130205 := proc(n)
option remember;
if n <= 2 then
n;
else
n^2-procname(n-1)-procname(n-2) ;
end if;
end proc:
seq(A130205(n), n=1..50) ; # R. J. Mathar, Aug 06 2016
MATHEMATICA
a[1]=1; a[2]=2; a[n_]:=a[n]=n^2-a[n-1]-a[n-2]; Table[a[n], {n, 100}]
a[ n_] := Quotient[ (n + 1)^2, 3] + 1 - Mod[n, 3]; (* Michael Somos, Aug 04 2016 *)
PROG
(PARI) a(n)=(n^2+2*n+4)\3 - n%3 \\ Charles R Greathouse IV, Aug 03 2016
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Zak Seidov, May 16 2007
STATUS
approved