%I #12 Dec 11 2020 11:36:48
%S 0,1,0,1,0,1,2,3,2,3,2,3,0,1,0,1,0,1,2,3,2,3,2,3,0,1,0,1,0,1,2,3,2,3,
%T 2,3,4,5,4,5,4,5,6,7,6,7,6,7,4,5,4,5,4,5,6,7,6,7,6,7,4,5,4,5,4,5,6,7,
%U 6,7,6,7,0,1,0,1,0,1,2,3,2,3,2,3,0,1,0,1,0,1,2,3,2,3,2,3,0,1,0,1,0,1,2,3,2,3
%N Starting from x_0 = n, iterate by dividing with 3 (discarding any remainder), until zero is reached: x_1 = floor(x_0/3), x_2 = floor(x_1/3), etc. Then a(n) = Sum_{i=0..} (x_i AND 2^i), where AND is bitwise-and.
%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%t Array[Total@ MapIndexed[BitAnd[2^First[#2 - 1], #1] &, NestWhileList[Floor[#/3] &, #, # > 0 &]] &, 106, 0] (* _Michael De Vlieger_, Dec 10 2020 *)
%o (PARI) A339601(n) = { my(i=0, s=0); while(n, s += bitand(2^i,n); i++; n \= 3); (s); };
%o (PARI) A339601(n) = { my(m=1, s=0); while(n>=m, s += bitand(m,n); m <<= 1; n \= 3); (s); };
%Y Cf. A004198, A037095.
%Y Cf. also A332497.
%K nonn,base
%O 0,7
%A _Antti Karttunen_, Dec 09 2020