OFFSET
0,3
LINKS
FORMULA
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 *)
PROG
(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
(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
CROSSREFS
KEYWORD
AUTHOR
N. J. A. Sloane, Sep 05 2001
STATUS
approved