OFFSET
1,2
COMMENTS
REFERENCES
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..2002 (first 200 terms from T. D. Noe)
R. K. Guy, Conway's RATS and other reversals, Amer. Math. Monthly, 96 (1989), 425-428.
Eric Weisstein's World of Mathematics, RATS Sequence.
FORMULA
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).
a(n+1) = A036839(a(n)). - Reinhard Zumkeller, Mar 14 2012
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
EXAMPLE
668 -> 668 + 866 = 1534 -> 1345.
MAPLE
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;
MATHEMATICA
NestList[FromDigits[Sort[IntegerDigits[#+FromDigits[Reverse[ IntegerDigits[#]]]]]]&, 1, 30] (* Harvey P. Dale, Nov 29 2011 *)
PROG
(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
(Haskell)
a004000_list = iterate a036839 1 -- Reinhard Zumkeller, Mar 14 2012
(PARI) step(n)=fromdigits(vecsort(digits(n+fromdigits(Vecrev(digits(n)))))) \\ Charles R Greathouse IV, Jun 23 2017
(Python)
l = [0, 1]
for n in range(2, 51):
x = str(l[n - 1])
l.append(int(''.join(sorted(str(int(x) + int(x[::-1]))))))
print(l[1:]) # Indranil Ghosh, Jul 05 2017
CROSSREFS
KEYWORD
base,nonn,nice,easy
AUTHOR
EXTENSIONS
Entry revised by N. J. A. Sloane, Jan 19 2002
STATUS
approved