login
A230629
a(0) = 0; thereafter a(n) = (1 + a(floor(n/2))) mod 3.
2
0, 1, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
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
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
See A230630 for another version.
Cf. A000523.
Sequence in context: A248640 A376562 A281083 * A027359 A236109 A279279
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Oct 30 2013
STATUS
approved