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.

A066200 a(1) = 1; for n > 1, a(n) = a(n-1)-(n+2) if this is positive and has not already appeared, otherwise a(n) = a(n-1)+(n+2).

Original entry on oeis.org

1, 5, 10, 4, 11, 3, 12, 2, 13, 25, 38, 24, 9, 25, 8, 26, 7, 27, 6, 28, 51, 75, 50, 76, 49, 21, 50, 20, 51, 19, 52, 18, 53, 17, 54, 16, 55, 15, 56, 14, 57, 101, 146, 100, 147, 99, 148, 98, 47, 99, 46, 100, 45, 101, 44, 102, 43, 103, 42, 104, 41, 105, 40, 106, 39, 107, 176
Offset: 1

Views

Author

N. J. A. Sloane, Dec 16 2001

Keywords

Crossrefs

A variant of A005132. A row of the array in A066201.

Programs

  • Maple
    S:= {1}:
    a[1]:= 1:
    for n from 2 to 100 do
      t:=a[n-1]-(n+2);
      if t > 0 and not member(t,S) then
        a[n]:= t
      else
        a[n]:= a[n-1]+(n+2)
      fi;
      S:= S union {a[n]}
    od:
    seq(a[n],n=1..100); # Robert Israel, Feb 10 2017
  • Python
    l=[0, 1]
    for n in range(2, 101):
        x=l[n - 1] - (n + 2)
        if x>0 and x not in l: l.append(x)
        else: l.append(l[n - 1] + (n + 2))
    print(l[1:]) # Indranil Ghosh, Jun 02 2017

Extensions

More terms from Vladeta Jovovic, Dec 16 2001