login
a(1)=1; a(2n)=(a(n)+1) mod 2, a(2n+1)=a(2n)+1.
0

%I #13 May 26 2023 16:21:38

%S 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,

%T 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,

%U 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

%N a(1)=1; a(2n)=(a(n)+1) mod 2, a(2n+1)=a(2n)+1.

%C Parity of sum(i=1,2n-1,a(i)) = parity of n.

%F a(2*A059010(n))=0; a(A059010(n))=1; a(2*A059009(n)+1)=2

%F Fixed point of morphism 0 -> 01, 1 -> 12, 2 -> 01.

%t 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 *)

%o (PARI) a(n)=if(n<2,1,if(n%2,(a(n-1)+1),(a(n/2)+1)%2))

%K nonn

%O 1,5

%A _Benoit Cloitre_, Mar 09 2004

%E Duplicate Mathematica program removed by _Harvey P. Dale_, May 26 2023