OFFSET
0,3
COMMENTS
For 0 < 2^i <= n < 2^(i+1), a(n) = ((i+1) mod 3).
For n >= 1, a(n) is the length of binary representation of n reduced modulo 3. - Antti Karttunen, Oct 10 2017
LINKS
FORMULA
G.f. g(z) satisfies: g(z) = z + 2*z^2 + 2*z^3 + (1 + z + ... + z^7)*g(z^8). - Robert Israel, Oct 10 2017
MAPLE
f:=proc(n) option remember; if n=0 then 0 else (1+f(floor(n/2))) mod 3; fi; end; [seq(f(n), n=0..120)];
MATHEMATICA
Join[{0}, Table[Mod[Floor[Log[2, n]] + 1, 3], {n, 80}]] (* Alonso del Arte, Oct 10 2017 *)
PROG
(Scheme, with memoization-macro definec)
(definec (A230629 n) (if (zero? n) n (modulo (+ 1 (A230629 (/ (- n (if (even? n) 0 1)) 2))) 3))) ;; Antti Karttunen, Oct 10 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Oct 30 2013
STATUS
approved