30
1
Your task is to generate the nth term of the RATS sequence, where n is the input. The RATS sequence is also known as the Reverse Add Then Sort sequence. This sequence can also be found here: http://oeis.org/A004000.
test cases:
0 > 1
1 > 2
2 > 4
3 > 8
4 > 16
5 > 77
6 > 145
7 > 668
For example, the output for 5 is 77 because 16 + 61 = 77. After this the 77 is sorted.
Shortest submission wins. This is my first challenge so i hope this is not a duplicate or something.
Does the input have to be an Integer or could it also be a string? – Denker – 2016-01-31T15:36:26.607
@DenkerAffe do you mean a number in the form of a string? – justaprogrammer – 2016-01-31T15:37:18.823
@justaprogrammer Yea, so I can get "123" instead of 123 as Integer. Would mayve save some bytes. – Denker – 2016-01-31T15:40:19.597
@DenkerAffe sure, if that works best – justaprogrammer – 2016-01-31T15:41:10.957
2isn't 77+77=154? Or have I missed something? EDIT: Oh, yes, I forgot to sort. – Denham Coote – 2016-02-01T10:48:00.113
6@DenhamCoote I think you meant "oh rat*s*, I forgot to sort!" – Martin Ender – 2016-02-02T10:49:26.700