login
a(n) = A289813(n) + A289814(n).
10

%I #23 Apr 22 2021 22:03:33

%S 0,1,1,2,3,3,2,3,3,4,5,5,6,7,7,6,7,7,4,5,5,6,7,7,6,7,7,8,9,9,10,11,11,

%T 10,11,11,12,13,13,14,15,15,14,15,15,12,13,13,14,15,15,14,15,15,8,9,9,

%U 10,11,11,10,11,11,12,13,13,14,15,15,14,15,15,12

%N a(n) = A289813(n) + A289814(n).

%C The ones in the binary representation of a(n) correspond to the nonzero digits in the ternary representation of n; for example: ternary(42) = 1120 and binary(a(42)) = 1110 (a(42) = 14).

%C Each number k >= 0 appears 2^A000120(k) times.

%C a(A004488(n)) = a(n).

%H Rémy Sigrist, <a href="/A289831/b289831.txt">Table of n, a(n) for n = 0..6560</a>

%F a(0) = 0.

%F a(3*n) = 2*a(n).

%F a(3*n + 1) = 2*a(n) + 1.

%F a(3*n + 2) = 2*a(n) + 1.

%e The first values, alongside the ternary representation of n, and the binary representation of a(n), are:

%e n a(n) ternary(n) binary(a(n))

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

%e 0 0 0 0

%e 1 1 1 1

%e 2 1 2 1

%e 3 2 10 10

%e 4 3 11 11

%e 5 3 12 11

%e 6 2 20 10

%e 7 3 21 11

%e 8 3 22 11

%e 9 4 100 100

%e 10 5 101 101

%e 11 5 102 101

%e 12 6 110 110

%e 13 7 111 111

%e 14 7 112 111

%e 15 6 120 110

%e 16 7 121 111

%e 17 7 122 111

%e 18 4 200 100

%e 19 5 201 101

%e 20 5 202 101

%e 21 6 210 110

%e 22 7 211 111

%e 23 7 212 111

%e 24 6 220 110

%e 25 7 221 111

%e 26 7 222 111

%t Table[FromDigits[Sign@ IntegerDigits[n, 3], 2], {n, 0, 100}] (* _Indranil Ghosh_, Aug 03 2017 *)

%o (PARI) a(n) = my (d=digits(n,3)); fromdigits(vector(#d, i, sign(d[i])), 2)

%o (Python)

%o from sympy.ntheory.factor_ import digits

%o from sympy import sign

%o def a(n):

%o d=digits(n, 3)[1:]

%o return int(''.join(str(sign(i)) for i in d), 2)

%o print([a(n) for n in range(101)]) # _Indranil Ghosh_, Aug 03 2017

%Y Cf. A000120, A004488, A289813, A289814.

%K nonn,base

%O 0,4

%A _Rémy Sigrist_, Jul 13 2017