login
A126234
a(0)=0; a(n)=a(n-1)-n, if a(n-1)>2n; otherwise a(n)=a(n-1)+n.
1
0, 1, 3, 6, 10, 15, 9, 16, 24, 15, 25, 14, 26, 39, 25, 40, 24, 41, 23, 42, 22, 43, 65, 42, 66, 41, 67, 40, 68, 39, 69, 38, 70, 37, 71, 36, 72, 109, 71, 110, 70, 111, 69, 112, 68, 113, 67, 114, 66, 115, 65, 116, 64, 117, 63, 118, 62, 119, 61, 120, 180, 119, 181, 118, 182, 117
OFFSET
0,3
LINKS
MAPLE
A[0]:= 0:
for n from 1 to 100 do
if A[n-1]>2*n then A[n]:= A[n-1]-n else A[n]:= A[n-1]+n fi
od:
seq(A[i], i=0..100); # Robert Israel, Nov 16 2016
MATHEMATICA
s={0}; a=0; Do[a=a+If[a>2n, -n, n]; AppendTo[s, a], {n, 200}]; s
nxt[{n_, a_}]:={n+1, If[a>2(n+1), a-n-1, a+n+1]}; NestList[nxt, {0, 0}, 70][[All, 2]] (* Harvey P. Dale, Feb 28 2022 *)
CROSSREFS
Sequence in context: A194037 A194101 A105333 * A259604 A130484 A074374
KEYWORD
nonn,look
AUTHOR
Zak Seidov, Mar 08 2007
STATUS
approved