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.

A063733 A variant of Recamán's sequence: a(0)=1, a(n) = a(n-1)-(n-1) if positive and new, else a(n) = a(n-1)+(n-1).

Original entry on oeis.org

1, 1, 2, 4, 7, 3, 8, 14, 21, 13, 22, 12, 23, 11, 24, 10, 25, 9, 26, 44, 63, 43, 64, 42, 19, 43, 18, 44, 17, 45, 16, 46, 15, 47, 80, 114, 79, 115, 78, 40, 79, 39, 80, 38, 81, 37, 82, 36, 83, 35, 84, 34, 85, 33, 86, 32, 87, 31, 88, 30, 89, 29, 90, 28, 91, 27
Offset: 0

Views

Author

N. J. A. Sloane, Sep 05 2001

Keywords

Crossrefs

See A005132, which is the main entry for this sequence. A063753 = 1 + A005132. A row of A066201. Also a row of A066202.
See also A078943.
Cf. A141126.

Programs

  • Haskell
    a063733 n = a063733_list !! n
    a063733_list = 1 : f 0 [1] where
       f x ys@(y:_) | u > 0 && u `notElem` ys = u : f (x + 1) (u : ys)
                    | otherwise               = v : f (x + 1) (v : ys)
                    where u = y - x; v = x + y
    -- Reinhard Zumkeller, Jul 02 2015
    
  • Mathematica
    a[0] = 1; a[n_] := a[n] = If[an = a[n-1] - (n-1); an > 0 && FreeQ[Array[a, n-1], an], an, a[n-1] + (n-1)]; Table[a[n], {n, 0, 65}] (* Jean-François Alcover, Feb 18 2018 *)
  • Python
    l=[1]
    for n in range(1, 101):
        x = l[n - 1] - (n - 1)
        if x > 0 and x not in l:
            l.append(x)
        else:
            l.append(l[n - 1] + (n - 1))
    print(l) # Indranil Ghosh, Jun 02 2017

Formula

a(n+1) = A005132(n) - 1; A005132 is Recamán's sequence. - Franklin T. Adams-Watters, Mar 12 2010