A289813 A binary encoding of the ones in ternary representation of n (see Comments for precise definition).
0, 1, 0, 2, 3, 2, 0, 1, 0, 4, 5, 4, 6, 7, 6, 4, 5, 4, 0, 1, 0, 2, 3, 2, 0, 1, 0, 8, 9, 8, 10, 11, 10, 8, 9, 8, 12, 13, 12, 14, 15, 14, 12, 13, 12, 8, 9, 8, 10, 11, 10, 8, 9, 8, 0, 1, 0, 2, 3, 2, 0, 1, 0, 4, 5, 4, 6, 7, 6, 4, 5, 4, 0, 1, 0, 2, 3, 2, 0, 1, 0, 16
Offset: 0
Examples
The first values, alongside the ternary representation of n, and the binary representation of a(n), are: n a(n) ternary(n) binary(a(n)) -- ---- ---------- ------------ 0 0 0 0 1 1 1 1 2 0 2 0 3 2 10 10 4 3 11 11 5 2 12 10 6 0 20 0 7 1 21 1 8 0 22 0 9 4 100 100 10 5 101 101 11 4 102 100 12 6 110 110 13 7 111 111 14 6 112 110 15 4 120 100 16 5 121 101 17 4 122 100 18 0 200 0 19 1 201 1 20 0 202 0 21 2 210 10 22 3 211 11 23 2 212 10 24 0 220 0 25 1 221 1 26 0 222 0
Links
- Rémy Sigrist, Table of n, a(n) for n = 0..6560
Programs
-
Mathematica
Table[FromDigits[#, 2] &[IntegerDigits[n, 3] /. 2 -> 0], {n, 0, 81}] (* Michael De Vlieger, Jul 20 2017 *)
-
PARI
a(n) = my (d=digits(n,3)); fromdigits(vector(#d, i, if (d[i]==1, 1, 0)), 2)
-
PARI
a(n) = fromdigits(digits(n, 3)%2, 2); \\ Ruud H.G. van Tol, May 08 2024
-
Python
from sympy.ntheory.factor_ import digits def a(n): d = digits(n, 3)[1:] return int("".join('1' if i==1 else '0' for i in d), 2) print([a(n) for n in range(51)]) # Indranil Ghosh, Jul 20 2017
Comments