%I #26 Feb 10 2025 15:14:52
%S 0,1,1,2,2,2,2,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,
%T 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,
%U 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
%N a(1)=0; thereafter a(n) = (1 + a(floor(n/2))) mod 3.
%C For 2^i <= n < 2^(i+1), a(n) = (i mod 3).
%H Antti Karttunen, <a href="/A230630/b230630.txt">Table of n, a(n) for n = 1..32768</a>
%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F a(n) = A000523(n) (mod 3). - _John M. Campbell_, Jul 15 2016
%p f:=proc(n) option remember; if n=1 then 0 else (1+f(floor(n/2))) mod 3; fi; end; [seq(f(n),n=1..120)];
%t Fold[Append[#1, Mod[1 + #1[[Floor[#2/2]]], 3]] &, {0}, Range[2, 105]] (* _Michael De Vlieger_, Oct 10 2017 *)
%o (PARI) a(n)=logint(n,2)%3 \\ _Charles R Greathouse IV_, Jul 15 2016
%o (Scheme)
%o ;; With memoization-macro definec.
%o (definec (A230630 n) (if (= 1 n) 0 (modulo (+ 1 (A230630 (/ (- n (if (even? n) 0 1)) 2))) 3))) ;; _Antti Karttunen_, Oct 10 2017
%Y See A230629 for another version.
%Y Cf. A000523, A030300, A030301.
%K nonn,easy
%O 1,4
%A _N. J. A. Sloane_, Oct 30 2013