login
Reverse and add (in base 3).
1

%I #25 Mar 31 2020 04:44:36

%S 1,2,4,8,16,32,96,160,320,960,1600,2880,3520,6080,11200,21440,62400,

%T 86080,169280,338560,648248,1902840,3281200,6404832,6510784,12950936,

%U 25744192,51882584,156278688,261609208,506142216,531792640,1008314456,2014504120

%N Reverse and add (in base 3).

%H T. D. Noe, <a href="/A035523/b035523.txt">Table of n, a(n) for n = 0..500</a>

%F a(n) = A055946(a(n-1)). - _R. J. Mathar_, May 28 2016

%e 32 = 1012, 1012 + 2101 = 10120 = 96.

%p A035523 := proc(n)

%p option remember;

%p if n =1 then

%p 1;

%p else

%p A055946(procname(n-1)) ;

%p end if;

%p end proc: # _R. J. Mathar_, May 28 2016

%t NestList[ (Fold[ 3 #1+#2&, 0, Reverse@IntegerDigits[ #, 3 ] ]+#&), 1, 40 ]

%t Join[{m = 1}, Table[m = m + FromDigits[Reverse[IntegerDigits[m, 3]], 3], {35}]] (* _T. D. Noe_, May 02 2012 *)

%t NestList[#+IntegerReverse[#,3]&,1,40] (* The program uses the IntegerRevese function from Mathematica version 10 *) (* _Harvey P. Dale_, Feb 21 2016 *)

%o (Python)

%o def reversedigits(n, b=10): # reverse digits of n in base b

%o x, y = n, 0

%o while x >= b:

%o x, r = divmod(x, b)

%o y = b*y + r

%o return b*y + x

%o A035523_list, l = [1], 1

%o for _ in range(50):

%o l += reversedigits(l, 3)

%o A035523_list.append(l)

%o # _Chai Wah Wu_, Jan 03 2015

%Y Cf. A035522.

%K nonn,easy,nice,base

%O 0,2

%A _N. J. A. Sloane_

%E More terms from _Wouter Meeussen_