login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A138376
a(n+1) = abs[ a(n) + (-1)^(n+1) * Sum_of_digits_of(n+1)], with a(0)=0.
1
0, 1, 3, 0, 4, 1, 7, 0, 8, 1, 2, 0, 3, 1, 6, 0, 7, 1, 10, 0, 2, 1, 5, 0, 6, 1, 9, 0, 10, 1, 4, 0, 5, 1, 8, 0, 9, 1, 12, 0, 4, 1, 7, 0, 8, 1, 11, 0, 12, 1, 6, 0, 7, 1, 10, 0, 11, 1, 14, 0, 6, 1, 9, 0, 10, 1, 13, 0, 14, 1, 8, 0, 9, 1, 12, 0, 13, 1, 16, 0, 8, 1, 11, 0, 12, 1, 15, 0, 16, 1, 10, 0, 11, 1, 14
OFFSET
0,3
COMMENTS
a(4*k)=0, with k>=1
a(4*k-2)=1, with k>=1
LINKS
MAPLE
P:=proc(n) local a, i, k, w; a:=0; print(a); for i from 1 by 1 to n do w:=0; k:=i; while k>0 do w:=w+k-(trunc(k/10)*10); k:=trunc(k/10); od; a:=abs(a+(-1)^i*w); print(a); od; end: P(100);
MATHEMATICA
nxt[{n_, a_}]:={n+1, Abs[a+(-1)^(n+1) Total[IntegerDigits[n+1]]]}; NestList[nxt, {0, 0}, 100][[All, 2]] (* Harvey P. Dale, Jan 04 2019 *)
CROSSREFS
Cf. A037123.
Sequence in context: A325491 A306803 A319974 * A077140 A003815 A306562
KEYWORD
easy,nonn,base
AUTHOR
EXTENSIONS
Definition corrected by N. J. A. Sloane, Jan 04 2019
STATUS
approved