cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A004000 RATS: Reverse Add Then Sort the digits applied to previous term, starting with 1.

This page as a plain text file.
%I A004000 M1137 #62 Feb 16 2025 08:32:27
%S A004000 1,2,4,8,16,77,145,668,1345,6677,13444,55778,133345,666677,1333444,
%T A004000 5567777,12333445,66666677,133333444,556667777,1233334444,5566667777,
%U A004000 12333334444,55666667777,123333334444,556666667777,1233333334444,5566666667777,12333333334444
%N A004000 RATS: Reverse Add Then Sort the digits applied to previous term, starting with 1.
%C A004000 It is conjectured that no matter what the starting term is, repeatedly applying RATS leads either to this sequence or into a cycle of finite length, such as those in A066710 and A066711.
%D A004000 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%H A004000 Alois P. Heinz, <a href="/A004000/b004000.txt">Table of n, a(n) for n = 1..2002</a> (first 200 terms from T. D. Noe)
%H A004000 R. K. Guy, <a href="http://www.jstor.org/stable/2325149">Conway's RATS and other reversals</a>, Amer. Math. Monthly, 96 (1989), 425-428.
%H A004000 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/RATSSequence.html">RATS Sequence</a>.
%F A004000 Let a(n) = k, form m by Reversing the digits of k, Add m to k Then Sort the digits of the sum into increasing order to get a(n+1).
%F A004000 a(n+1) = A036839(a(n)). - _Reinhard Zumkeller_, Mar 14 2012
%F A004000 A010888(a(n)) = A153130(n-1). - _Ivan N. Ianakiev_, Nov 27 2014
%F A004000 a(2n-1) = (37 * 10^(n-3) + 3332)/3, n >= 11; a(2n) = (167 * 10^(n-3) + 3331)/3, n >= 10. - _Jianing Song_, May 06 2021
%e A004000 668 -> 668 + 866 = 1534 -> 1345.
%p A004000 read transforms; RATS := n -> digsort(n + digrev(n)); b := [1]; t := [1]; for n from 1 to 50 do t := RATS(t); b := [op(b),t]; od: b;
%t A004000 NestList[FromDigits[Sort[IntegerDigits[#+FromDigits[Reverse[ IntegerDigits[#]]]]]]&,1,30] (* _Harvey P. Dale_, Nov 29 2011 *)
%o A004000 (Magma) [ n eq 1 select 1 else Seqint(Reverse(Sort(Intseq(p + Seqint(Reverse(Intseq(p))) where p is Self(n-1))))) : n in [1..10]]; // Sergei Haller (sergei(AT)sergei-haller.de), Dec 21 20061
%o A004000 (Haskell)
%o A004000 a004000_list = iterate a036839 1  -- _Reinhard Zumkeller_, Mar 14 2012
%o A004000 (PARI) step(n)=fromdigits(vecsort(digits(n+fromdigits(Vecrev(digits(n)))))) \\ _Charles R Greathouse IV_, Jun 23 2017
%o A004000 (Python)
%o A004000 l = [0, 1]
%o A004000 for n in range(2, 51):
%o A004000     x = str(l[n - 1])
%o A004000     l.append(int(''.join(sorted(str(int(x) + int(x[::-1]))))))
%o A004000 print(l[1:]) # _Indranil Ghosh_, Jul 05 2017
%Y A004000 Cf. A036839, A066710, A066711, A066713, A164338, A161593, A114611, A114612, A209878, A209879, A209880.
%K A004000 base,nonn,nice,easy
%O A004000 1,2
%A A004000 _N. J. A. Sloane_
%E A004000 Entry revised by _N. J. A. Sloane_, Jan 19 2002