cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A292372 A binary encoding of 2-digits in base-4 representation of n.

This page as a plain text file.
%I A292372 #25 Jun 30 2022 14:44:03
%S A292372 0,0,1,0,0,0,1,0,2,2,3,2,0,0,1,0,0,0,1,0,0,0,1,0,2,2,3,2,0,0,1,0,4,4,
%T A292372 5,4,4,4,5,4,6,6,7,6,4,4,5,4,0,0,1,0,0,0,1,0,2,2,3,2,0,0,1,0,0,0,1,0,
%U A292372 0,0,1,0,2,2,3,2,0,0,1,0,0,0,1,0,0,0,1,0,2,2,3,2,0,0,1,0,4,4,5,4,4,4,5,4,6,6,7,6,4,4,5,4,0,0,1,0,0,0,1,0,2
%N A292372 A binary encoding of 2-digits in base-4 representation of n.
%H A292372 Antti Karttunen, <a href="/A292372/b292372.txt">Table of n, a(n) for n = 0..65536</a>
%H A292372 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F A292372 a(n) = A059906(n AND A048724(n)), where AND is a bitwise-AND (A004198).
%F A292372 For all n >= 0, A000120(a(n)) = A160382(n).
%e A292372    n      a(n)     base-4(n)  binary(a(n))
%e A292372                   A007090(n)  A007088(a(n))
%e A292372   --      ----    ----------  ------------
%e A292372    1        0          1           0
%e A292372    2        1          2           1
%e A292372    3        0          3           0
%e A292372    4        0         10           0
%e A292372    5        0         11           0
%e A292372    6        1         12           1
%e A292372    7        0         13           0
%e A292372    8        2         20          10
%e A292372    9        2         21          10
%e A292372   10        3         22          11
%e A292372   11        2         23          10
%e A292372   12        0         30           0
%e A292372   13        0         31           0
%e A292372   14        1         32           1
%e A292372   15        0         33           0
%e A292372   16        0        100           0
%e A292372   17        0        101           0
%e A292372   18        1        102           1
%t A292372 Table[FromDigits[IntegerDigits[n, 4] /. k_ /; IntegerQ@ k :> If[k == 2, 1, 0], 2], {n, 0, 120}] (* _Michael De Vlieger_, Sep 21 2017 *)
%o A292372 (Scheme, with memoization-macro definec)
%o A292372 (definec (A292372 n) (if (zero? n) n (let ((d (modulo n 4))) (+ (if (= 2 d) 1 0) (* 2 (A292372 (/ (- n d) 4)))))))
%o A292372 (Python)
%o A292372 from sympy.ntheory.factor_ import digits
%o A292372 def a(n):
%o A292372     k=digits(n, 4)[1:]
%o A292372     return 0 if n==0 else int("".join('1' if i==2 else '0' for i in k), 2)
%o A292372 print([a(n) for n in range(121)]) # _Indranil Ghosh_, Sep 21 2017
%o A292372 (Python)
%o A292372 def A292372(n): return 0 if (m:=n&~(n<<1)) < 2 else int(bin(m)[-2:1:-2][::-1],2) # _Chai Wah Wu_, Jun 30 2022
%Y A292372 Cf. A004198, A007088, A007090, A048724, A059906, A160382, A292370, A292371, A292373.
%Y A292372 Cf. A289814 (analogous sequence for base-3).
%K A292372 nonn,base
%O A292372 0,9
%A A292372 _Antti Karttunen_, Sep 15 2017