cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A125577 a(0) = 1; for n >= 1, a(n) = n^2 - a(n-1).

Original entry on oeis.org

1, 0, 4, 5, 11, 14, 22, 27, 37, 44, 56, 65, 79, 90, 106, 119, 137, 152, 172, 189, 211, 230, 254, 275, 301, 324, 352, 377, 407, 434, 466, 495, 529, 560, 596, 629, 667, 702, 742, 779, 821, 860, 904, 945, 991, 1034, 1082, 1127, 1177, 1224, 1276, 1325, 1379, 1430
Offset: 0

Views

Author

John C. George (John.George(AT)ENMU.edu), Jan 03 2007

Keywords

Comments

A sequence given by a recurrence that is almost polynomial; it cannot be expressed as a polynomial, but is bounded by n^2.
If we let a(0) = 0, the triangular numbers result; a typo led to the new sequence.

Examples

			a(0)=1, so a(1) = 1^2 - 1 = 0; a(2) = 2^2 - 0 = 4; a(3) = 9 - 4 = 5; etc.
		

Crossrefs

Cf. A000217.

Programs

  • Magma
    [1] cat [n le 1 select n-1 else n^2-Self(n-1): n in [1..50]]; // Vincenzo Librandi, May 19 2014
  • Mathematica
    a[0] := 1 a[n_] := n^2 - a[n - 1]
    CoefficientList[Series[(-1 + 2 x - 4 x^2 + x^3)/((-1 + x)^3 (1 + x)), {x, 0, 50}], x] (* Vincenzo Librandi, May 19 2014 *)
  • Python
    a = 1
    for n in range(1,77):
        print(a, end=',')
        a = n*n - a
    

Formula

O.g.f.: (-1+2*x-4*x^2+x^3)/((-1+x)^3*(1+x)). a(n) = -n-1+(-1)^n+A000217(n+1). - R. J. Mathar, Dec 05 2007
a(n) = n*(n+1)/2 + (-1)^n = A000217(n) + (-1)^n. - Franklin T. Adams-Watters, Jul 13 2014
E.g.f.: exp(x)*(x+x^2/2) + exp(-x). - Franklin T. Adams-Watters, Jul 13 2014

Extensions

Name corrected by Alex Ratushnyak, Aug 03 2012