login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A binary encoding of the zeros in base-4 representation of n.
5

%I #21 May 15 2021 06:16:58

%S 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,3,2,2,2,1,0,0,0,1,0,0,0,1,0,0,0,3,2,

%T 2,2,1,0,0,0,1,0,0,0,1,0,0,0,3,2,2,2,1,0,0,0,1,0,0,0,1,0,0,0,7,6,6,6,

%U 5,4,4,4,5,4,4,4,5,4,4,4,3,2,2,2,1,0,0,0,1,0,0,0,1,0,0,0,3,2,2,2,1,0,0,0,1,0,0,0,1,0,0,0,3,2,2,2,1,0,0,0,1

%N A binary encoding of the zeros in base-4 representation of n.

%H Antti Karttunen, <a href="/A292370/b292370.txt">Table of n, a(n) for n = 0..65536</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F For all n >= 0, A000120(a(n)) = A160380(n).

%e n a(n) base-4(n) binary(a(n))

%e A007090(n) A007088(a(n))

%e -- ---- ---------- ------------

%e 1 0 1 0

%e 2 0 2 0

%e 3 0 3 0

%e 4 1 10 1

%e 5 0 11 0

%e 6 0 12 0

%e 7 0 13 0

%e 8 1 20 1

%e 9 0 21 0

%e 10 0 22 0

%e 11 0 23 0

%e 12 1 30 1

%e 13 0 31 0

%e 14 0 32 0

%e 15 0 33 0

%e 16 3 100 11

%e 17 2 101 10

%t Table[FromDigits[IntegerDigits[n, 4] /. k_ /; IntegerQ@ k :> If[k == 0, 1, 0], 2], {n, 0, 120}] (* _Michael De Vlieger_, Sep 21 2017 *)

%o (Scheme) (define (A292370 n) (if (zero? n) n (let loop ((n n) (b 1) (s 0)) (if (< n 4) s (let ((d (modulo n 4))) (if (zero? d) (loop (/ n 4) (+ b b) (+ s b)) (loop (/ (- n d) 4) (+ b b) s)))))))

%o (Python)

%o from sympy.ntheory.factor_ import digits

%o def a(n):

%o k=digits(n, 4)[1:]

%o return 0 if n==0 else int("".join('1' if i==0 else '0' for i in k), 2)

%o print([a(n) for n in range(111)]) # _Indranil Ghosh_, Sep 21 2017

%Y Cf. A007088, A007090, A160380, A292371, A292372, A292373.

%Y Cf. A291770 (analogous sequence for base-3).

%K nonn,base

%O 0,17

%A _Antti Karttunen_, Sep 15 2017