login
Reverse and add (in base 4).
7

%I #19 Mar 04 2020 22:57:52

%S 1,2,4,5,10,20,25,50,85,170,340,425,850,1385,3070,6140,10225,15335,

%T 29410,65135,129070,317675,1280860,2163725,3999775,7999550,20321515,

%U 81946460,138412045,255852575,511705150,1300234475,5242880860

%N Reverse and add (in base 4).

%H Reinhard Zumkeller, <a href="/A035524/b035524.txt">Table of n, a(n) for n = 0..1000</a>

%H <a href="/index/Res#RAA">Index entries for sequences related to Reverse and Add!</a>

%F a(n+1) = A055948(a(n)), a(0) = 1. [_Reinhard Zumkeller_, Oct 10 2011]

%t nxt4[n_]:=Module[{idn4=IntegerDigits[n,4]},FromDigits[idn4+ Reverse[idn4], 4]]; NestList[nxt4,1,40] (* _Harvey P. Dale_, May 02 2011 *)

%o (Haskell)

%o a035524 n = a035524_list !! n

%o a035524_list = iterate a055948 1

%o -- _Reinhard Zumkeller_, Oct 10 2011

%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 A035524_list, l = [1], 1

%o for _ in range(50):

%o ....l += reversedigits(l,4)

%o ....A035524_list.append(l)

%Y Cf. A035522.

%Y Cf. A030103.

%K nonn,easy,nice,base

%O 0,2

%A _N. J. A. Sloane_

%E More terms from Larry Reeves (larryr(AT)acm.org), Sep 22 2000