OFFSET
0,3
COMMENTS
Same seed, b(n) = n*(n+1) - b(n-2) : 0, 1, 6, 11, 14, 19, 28, 37, 44, 53, 66, 79, 90, 103, 120, 137, 152, 169, 190, 211, 230, 251, 276, 301, 324, 349, 378, 407, 434, 463, 496, 529, 560, 593, ...
b(n) = a(n+1) - 1 if (n mod 4) < 2, otherwise b(n) = a(n+1) + 1.
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (3,-4,4,-3,1).
FORMULA
G.f.: x*(1-x+3*x^2-x^3)/(1-3*x+4*x^2-4*x^3+3*x^4-x^5). - David Scambler, Aug 06 2012
a(n) = (n^2 +n -1 +cos(pi*n/2) +sin(pi*n/2))/2. - Vaclav Kotesovec, Aug 11 2012
MATHEMATICA
CoefficientList[Series[(x -x^2 +3x^3 -x^4)/(1 -3x +4x^2 -4x^3 +3x^4 -x^5), {x, 0, 70}], x] (* Vincenzo Librandi, Jul 18 2013 *)
RecurrenceTable[{a[0]==0, a[1]==1, a[n]==n(n-1)-a[n-2]}, a, {n, 60}] (* or *) LinearRecurrence[{3, -4, 4, -3, 1}, {0, 1, 2, 5, 10}, 60] (* Harvey P. Dale, May 15 2016 *)
PROG
(Python)
prpr = 0
prev = 1
for n in range(2, 77):
print(prpr, end=', ')
curr = n*(n-1) - prpr
prpr = prev
prev = curr
(Magma) [n le 2 select n-1 else 2*Binomial(n-1, 2) -Self(n-2): n in [1..81]]; // G. C. Greubel, Nov 25 2022
(SageMath)
def A215098(n):
if (n<2): return n
else: return 2*binomial(n, 2) - A215098(n-2)
[A215098(n) for n in range(81)] # G. C. Greubel, Nov 25 2022
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Alex Ratushnyak, Aug 03 2012
STATUS
approved