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.

A053461 a(0) = 0; a(n) = a(n-1) - n^2 if positive and new, otherwise a(n) = a(n-1) + n^2.

Original entry on oeis.org

0, 1, 5, 14, 30, 55, 19, 68, 4, 85, 185, 64, 208, 39, 235, 10, 266, 555, 231, 592, 192, 633, 149, 678, 102, 727, 51, 780, 1564, 723, 1623, 662, 1686, 597, 1753, 528, 1824, 455, 1899, 378, 1978, 297, 2061, 212, 2148, 123, 2239, 4448, 2144, 4545
Offset: 0

Views

Author

N. J. A. Sloane, Feb 09 2002

Keywords

Comments

'Recamán transform' (see A005132) of the squares.

Crossrefs

Cf. A076042 ('Easy Recamán transform' of the squares), A064365 ('Recamán transform' of the primes).

Programs

  • Mathematica
    a = {0, 1}; Do[If[a[[-1]] - n^2 >= 0 && Position[a, a[[-1]] - n^2] == {}, a = Append[a, a[[-1]] - n^2], a = Append[a, a[[-1]] + n^2]], {n, 2, 49}]; Print[a] (* Samuel Harkness, Sep 20 2022 *)
  • PARI
    lista(nn) = {my(va = vector(nn)); va[1] = 1; my(sa = Set(va)); for (n=2, nn, my(x = va[n-1] - n^2); if ((x>0) && !setsearch(sa, x), va[n] = x, va[n] =  va[n-1] + n^2); sa = Set(va);); concat(0, va);} \\ Michel Marcus, Sep 26 2022