OFFSET
0,2
MAPLE
a[0]:=1: S:={1}: for n from 1 to 100 do if member(n, S)=false then a[n]:=abs(a[n-1]-n): S:=S union {a[n]} else a[n]:=a[n-1]+n: S:=S union {a[n]} fi od: seq(a[n], n=0..100); # Emeric Deutsch, May 07 2006
MATHEMATICA
f[s_] := Block[{n, }, n = Length[s]; Return[Append[s, Abs[Last[s] + If[MemberQ[s, n], +n, -n]]]]; ]; Nest[f, {1}, 100] (* Ray Chandler, May 06 2006 *)
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Leroy Quet, May 05 2006
EXTENSIONS
Extended by Ray Chandler and Emeric Deutsch, May 06 2006
STATUS
approved