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”).

A091830
a(1)=1; a(2n)=(a(n)+1) mod 2, a(2n+1)=a(2n)+1.
0
1, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 0, 1, 1, 2, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 0, 1, 1, 2, 0, 1, 1, 2, 1, 2, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 0, 1, 1, 2, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 0, 1, 1, 2, 1, 2, 0, 1, 1, 2
OFFSET
1,5
COMMENTS
Parity of sum(i=1,2n-1,a(i)) = parity of n.
FORMULA
a(2*A059010(n))=0; a(A059010(n))=1; a(2*A059009(n)+1)=2
Fixed point of morphism 0 -> 01, 1 -> 12, 2 -> 01.
MATHEMATICA
a[1] = 1; a[n_] := a[n] = If[ EvenQ[n], Mod[ a[n/2] + 1, 2], a[n - 1] + 1]; Table[ a[n], {n, 105}] (* Robert G. Wilson v, Nov 03 2005 *)
PROG
(PARI) a(n)=if(n<2, 1, if(n%2, (a(n-1)+1), (a(n/2)+1)%2))
CROSSREFS
Sequence in context: A324572 A153148 A378437 * A029427 A353506 A343380
KEYWORD
nonn
AUTHOR
Benoit Cloitre, Mar 09 2004
EXTENSIONS
Duplicate Mathematica program removed by Harvey P. Dale, May 26 2023
STATUS
approved