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.

A291770 A binary encoding of the zeros in ternary representation of n.

This page as a plain text file.
%I A291770 #20 May 15 2021 06:18:08
%S A291770 0,0,1,0,0,1,0,0,3,2,2,1,0,0,1,0,0,3,2,2,1,0,0,1,0,0,7,6,6,5,4,4,5,4,
%T A291770 4,3,2,2,1,0,0,1,0,0,3,2,2,1,0,0,1,0,0,7,6,6,5,4,4,5,4,4,3,2,2,1,0,0,
%U A291770 1,0,0,3,2,2,1,0,0,1,0,0,15,14,14,13,12,12,13,12,12,11,10,10,9,8,8,9,8,8,11,10,10,9,8,8,9,8,8,7,6,6
%N A291770 A binary encoding of the zeros in ternary representation of n.
%C A291770 The ones in the binary representation of a(n) correspond to the nonleading zeros in the ternary representation of n. For example: ternary(33) = 1020 and binary(a(33)) = 101 (a(33) = 5).
%H A291770 Antti Karttunen, <a href="/A291770/b291770.txt">Table of n, a(n) for n = 1..59049</a>
%F A291770 For all n >= 0, a(A000244(n)) = A000225(n), that is, a(3^n) = (2^n) - 1. [The records in the sequence].
%F A291770 For all n >= 1, A000120(a(n)) = A077267(n).
%F A291770 For all n >= 1, A278222(a(n)) = A291771(n).
%e A291770    n      a(n)    ternary(n)  binary(a(n))
%e A291770                   A007089(n)  A007088(a(n))
%e A291770   --      ----    ----------  ------------
%e A291770    1        0            1           0
%e A291770    2        0            2           0
%e A291770    3        1           10           1
%e A291770    4        0           11           0
%e A291770    5        0           12           0
%e A291770    6        1           20           1
%e A291770    7        0           21           0
%e A291770    8        0           22           0
%e A291770    9        3          100          11
%e A291770   10        2          101          10
%e A291770   11        2          102          10
%e A291770   12        1          110           1
%e A291770   13        0          111           0
%e A291770   14        0          112           0
%e A291770   15        1          120           1
%e A291770   16        0          121           0
%e A291770   17        0          122           0
%e A291770   18        3          200          11
%e A291770   19        2          201          10
%e A291770   20        2          202          10
%e A291770   21        1          210           1
%e A291770   22        0          211           0
%e A291770   23        0          212           0
%e A291770   24        1          220           1
%e A291770   25        0          221           0
%e A291770   26        0          222           0
%e A291770   27        7         1000         111
%e A291770   28        6         1001         110
%e A291770   29        6         1002         110
%e A291770   30        5         1010         101
%t A291770 Table[FromDigits[IntegerDigits[n, 3] /. k_ /; k < 3 :> If[k == 0, 1, 0], 2], {n, 110}] (* _Michael De Vlieger_, Sep 11 2017 *)
%o A291770 (Scheme) (define (A291770 n) (if (zero? n) n (let loop ((n n) (b 1) (s 0)) (if (< n 3) s (let ((d (modulo n 3))) (if (zero? d) (loop (/ n 3) (+ b b) (+ s b)) (loop (/ (- n d) 3) (+ b b) s)))))))
%o A291770 (Python)
%o A291770 from sympy.ntheory.factor_ import digits
%o A291770 def a(n):
%o A291770     k=digits(n, 3)[1:]
%o A291770     return int("".join('1' if i==0 else '0' for i in k), 2)
%o A291770 print([a(n) for n in range(1, 111)]) # _Indranil Ghosh_, Sep 21 2017
%Y A291770 Cf. A007088, A007089, A077267, A289813, A289814, A291771.
%K A291770 nonn,base
%O A291770 1,9
%A A291770 _Antti Karttunen_, Sep 11 2017