%I #35 Mar 17 2021 08:02:55
%S 0,1,-2,1,4,-11,-2,7,-8,1,10,-5,4,13,-38,-11,16,-29,-2,25,-20,7,34,
%T -35,-8,19,-26,1,28,-17,10,37,-32,-5,22,-23,4,31,-14,13,40,-119,-38,
%U 43,-92,-11,70,-65,16,97,-110,-29,52,-83,-2,79,-56,25,106,-101,-20,61,-74,7,88,-47,34,115,-116,-35,46,-89,-8,73,-62,19,100
%N Reversal of n in balanced ternary representation.
%C As the graph demonstrates, the sequence makes large negative steps at terms (3^i+1)/2. These steps divide the graph into conspicuous blocks. - _N. J. A. Sloane_, Jul 03 2016
%D D. E. Knuth, The Art of Computer Programming, Addison-Wesley, Reading, MA, Vol 2, pp 173-175.
%H Reinhard Zumkeller, <a href="/A134028/b134028.txt">Table of n, a(n) for n = 0..10000</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Reversal.html">Reversal</a>
%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Balanced_ternary">Balanced Ternary</a>
%F a(A134027(n)) = A134027(n);
%F A134021(ABS(a(n))) <= A134021(n).
%e 20 = 1*3^3 - 1*3^2 + 1*3^1 - 1*3^0 == '+-+-'
%e => a(20) = -1*3^3 + 1*3^2 - 1*3^1 + 1*3^0 = -20;
%e 21 = 1*3^3 - 1*3^2 + 1*3^1 + 0*3^0 == '+-+0'
%e => a(21) = 0*3^3 + 1*3^2 - 1*3^1 + 1*3^0 = 7;
%e 22 = 1*3^3 - 1*3^2 + 1*3^1 + 1*3^0 == '+-++'
%e => a(22) = 1*3^3 + 1*3^2 - 1*3^1 + 1*3^0 = 34;
%e 23 = 1*3^3 + 0*3^2 - 1*3^1 - 1*3^0 == '+0--'
%e => a(23) = -1*3^3 - 1*3^2 + 0*3^1 + 1*3^0 = -35;
%e 24 = 1*3^3 + 0*3^2 - 1*3^1 + 0*3^0 == '+0-0'
%e => a(24) = 0*3^3 - 1*3^2 + 0*3^1 + 1*3^0 = -8;
%e 25 = 1*3^3 + 0*3^2 - 1*3^1 + 1*3^0 == '+0-+'
%e => a(25) = 1*3^3 - 1*3^2 + 0*3^1 + 1*3^0 = 19.
%o (Python)
%o def a(n):
%o if n==0: return 0
%o s=[]
%o x=0
%o while n>0:
%o x=n%3
%o n=n//3
%o if x==2:
%o x=-1
%o n+=1
%o s.append(x)
%o l=s[::-1]
%o return sum(l[i]*3**i for i in range(len(l)))
%o print([a(n) for n in range(101)]) # _Indranil Ghosh_, Jun 10 2017
%Y Cf. A117966 (balanced ternary representation), A030102, A134021, A274107.
%Y A134027 gives the numbers whose balanced ternary representation is palindromic.
%K sign,look,base
%O 0,3
%A _Reinhard Zumkeller_, Oct 19 2007
|