login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

The positions of nonzero digits in the balanced ternary expansions of n and a(n) are the same, and the k-th rightmost nonzero digit in a(n) equals the product of the k rightmost nonzero digits in n.
4

%I #10 May 10 2022 02:26:13

%S 0,1,-4,3,4,11,-12,-11,-10,9,10,-13,12,13,-34,33,34,35,-36,-35,32,-33,

%T -32,29,-30,-29,-28,27,28,-31,30,31,38,-39,-38,-37,36,37,-40,39,40,

%U 101,-102,-101,-100,99,100,-103,102,103,-106,105,106,107,-108,-107,104

%N The positions of nonzero digits in the balanced ternary expansions of n and a(n) are the same, and the k-th rightmost nonzero digit in a(n) equals the product of the k rightmost nonzero digits in n.

%C This sequence can naturally be extended to negative integers; we then obtain a permutation of the integers (Z).

%C A number is a fixed point of this sequence iff it has no digit -1 in its balanced ternary expansion (A005836).

%H Rémy Sigrist, <a href="/A353830/b353830.txt">Table of n, a(n) for n = 0..6561</a>

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

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

%F Sum_{k = 0..n} a(n) = 0 iff n belongs to A029858.

%e The first terms, in decimal and in balanced ternary, are:

%e n a(n) bter(n) bter(a(n))

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

%e 0 0 0 0

%e 1 1 1 1

%e 2 -4 1T TT

%e 3 3 10 10

%e 4 4 11 11

%e 5 11 1TT 11T

%e 6 -12 1T0 TT0

%e 7 -11 1T1 TT1

%e 8 -10 10T T0T

%e 9 9 100 100

%e 10 10 101 101

%e 11 -13 11T TTT

%e 12 12 110 110

%o (PARI) a(n) = {

%o my (d=[], t, p=1);

%o while (n, d=concat(t=[0,1,-1][1+n%3], d); n=(n-t)/3);

%o forstep (k=#d, 1, -1, if (d[k], d[k]=p*=d[k]));

%o fromdigits(d,3);

%o }

%Y See A305458, A353824, A353826, A353828 for similar sequences.

%Y Cf. A005836 (fixed points), A029858, A153775.

%K sign,base

%O 0,3

%A _Rémy Sigrist_, May 08 2022