login
A066203
a(1) = 2; a(2) = 1; for n > 2, a(n) = a(n-1)-(n-1) if this is positive and has not already appeared in the sequence, otherwise a(n) = a(n-1)+(n-1).
2
2, 1, 3, 6, 10, 5, 11, 4, 12, 21, 31, 20, 8, 21, 7, 22, 38, 55, 37, 18, 38, 17, 39, 16, 40, 15, 41, 14, 42, 13, 43, 74, 106, 73, 107, 72, 36, 73, 35, 74, 34, 75, 33, 76, 32, 77, 123, 170, 122, 171, 121, 70, 122, 69, 123, 68, 124, 67, 9, 68, 128, 189, 127, 64, 128, 63, 129, 62
OFFSET
1,1
PROG
(Python)
l=[0, 2, 1]
for n in range(3, 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[1:]) # Indranil Ghosh, Jun 02 2017
CROSSREFS
A variant of A005132. A row of the array in A066202.
Sequence in context: A057925 A086964 A076242 * A329101 A024866 A076058
KEYWORD
nonn,easy
AUTHOR
N. J. A. Sloane, Dec 16 2001
EXTENSIONS
More terms from Sascha Kurz, Mar 24 2002
STATUS
approved