OFFSET
0,4
COMMENTS
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..6560
FORMULA
a(0) = 0.
a(3*n) = 2*a(n).
a(3*n + 1) = 2*a(n) + 1.
a(3*n + 2) = 2*a(n) + 1.
EXAMPLE
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 1 2 1
3 2 10 10
4 3 11 11
5 3 12 11
6 2 20 10
7 3 21 11
8 3 22 11
9 4 100 100
10 5 101 101
11 5 102 101
12 6 110 110
13 7 111 111
14 7 112 111
15 6 120 110
16 7 121 111
17 7 122 111
18 4 200 100
19 5 201 101
20 5 202 101
21 6 210 110
22 7 211 111
23 7 212 111
24 6 220 110
25 7 221 111
26 7 222 111
MATHEMATICA
Table[FromDigits[Sign@ IntegerDigits[n, 3], 2], {n, 0, 100}] (* Indranil Ghosh, Aug 03 2017 *)
PROG
(PARI) a(n) = my (d=digits(n, 3)); fromdigits(vector(#d, i, sign(d[i])), 2)
(Python)
from sympy.ntheory.factor_ import digits
from sympy import sign
def a(n):
d=digits(n, 3)[1:]
return int(''.join(str(sign(i)) for i in d), 2)
print([a(n) for n in range(101)]) # Indranil Ghosh, Aug 03 2017
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jul 13 2017
STATUS
approved