login
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).
2
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,2
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
PROG
(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
CROSSREFS
A variant of A005132. A row of the array in A066201.
Sequence in context: A388063 A054513 A295121 * A357913 A053822 A376487
KEYWORD
nonn,easy,look
AUTHOR
N. J. A. Sloane, Dec 16 2001
EXTENSIONS
More terms from Vladeta Jovovic, Dec 16 2001
STATUS
approved