login
A291770
A binary encoding of the zeros in ternary representation of n.
10
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, 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, 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
OFFSET
1,9
COMMENTS
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).
LINKS
FORMULA
For all n >= 0, a(A000244(n)) = A000225(n), that is, a(3^n) = (2^n) - 1. [The records in the sequence].
For all n >= 1, A000120(a(n)) = A077267(n).
For all n >= 1, A278222(a(n)) = A291771(n).
EXAMPLE
n a(n) ternary(n) binary(a(n))
A007089(n) A007088(a(n))
-- ---- ---------- ------------
1 0 1 0
2 0 2 0
3 1 10 1
4 0 11 0
5 0 12 0
6 1 20 1
7 0 21 0
8 0 22 0
9 3 100 11
10 2 101 10
11 2 102 10
12 1 110 1
13 0 111 0
14 0 112 0
15 1 120 1
16 0 121 0
17 0 122 0
18 3 200 11
19 2 201 10
20 2 202 10
21 1 210 1
22 0 211 0
23 0 212 0
24 1 220 1
25 0 221 0
26 0 222 0
27 7 1000 111
28 6 1001 110
29 6 1002 110
30 5 1010 101
MATHEMATICA
Table[FromDigits[IntegerDigits[n, 3] /. k_ /; k < 3 :> If[k == 0, 1, 0], 2], {n, 110}] (* Michael De Vlieger, Sep 11 2017 *)
PROG
(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)))))))
(Python)
from sympy.ntheory.factor_ import digits
def a(n):
k=digits(n, 3)[1:]
return int("".join('1' if i==0 else '0' for i in k), 2)
print([a(n) for n in range(1, 111)]) # Indranil Ghosh, Sep 21 2017
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Sep 11 2017
STATUS
approved