Lychrel numbers: Difference between revisions

m
added whitespace to the task's preamble, aligned some columnar numbers.
m (→‎{{Header|REXX}}: changed whitespace and indentations.)
m (added whitespace to the task's preamble, aligned some columnar numbers.)
Line 1:
[[Category:Palindromes]]
{{task}}
::#   Take an integer n, greater than zero.
::#   Form the next n of its series by reversing the digits of the current n and adding the result to the current n.
::#   Stop when n becomes palindromic - i.e. the digits of n in reverse order == n.
 
<br>
The above recurrence relation when applied to most starting numbers n = 1, 2, ... terminates in a palindrome quite quickly, for example if n<sub>0</sub> = 12 we get.
 
<pre>12
 
12 + 21 = 33, a palindrome!</pre>
;Example:
If n<sub>0</sub> = 12 we get
<pre>12
12
12 + 21 = 33, a palindrome!</pre>
...</pre>
 
And if n<sub>0</sub> = 55 we get
<pre>55
55 + 55 = 110 55
55 + 55 = 110
110 + 011 = 121, a palindrome!</pre>
</pre>
 
Notice that the check for a palindrome happens &nbsp; ''after'' &nbsp; an addition.
 
 
Some starting numbers seem to go on forever; the recurrence relation for 196 has been calculated for millions of repetitions forming numbers with millions of digits, without forming a palindrome. These numbers that do not end in a palindrome are called '''Lychrel numbers'''.
 
These numbers that do not end in a palindrome are called '''Lychrel numbers'''.
 
For the purposes of this task a Lychrel number is any starting number that does not form a palindrome within 500 (or more) iterations.
Line 27 ⟶ 37:
 
In general, any sequence from one Lychrel number ''might'' converge to join the sequence from a prior Lychrel number candidate; for example the sequences for the numbers 196 and then 689 begin:
<pre>196
196 + 691 = 887 196
887 196 + 788 691 = 1675 887
1675 887 + 5761 788 = 7436 1675
7436 1675 + 6347 5761 = 13783 7436
13783 7436 + 38731 6347 = 5251413783
52514 13783 + 41525 38731 = 9403952514
52514 + 41525 = 94039
...
...
 
 
689
689 + 986 = 1675
1675 + 5761 = 7436
...
</pre>
So we see that the sequence starting with 689 converges to, and continues with the same numbers as that for 196.
 
So we see that the sequence starting with 689 converges to, and continues with the same numbers as that for 196. Because of this we can further split the Lychrel numbers into true '''Seed''' Lychrel number candidates, and '''Related''' numbers that produce no palindromes but have integers in their sequence seen as part of the sequence generated from a lower Lychrel number.
689
689 + 986 = 1675
1675 + 5761 = 7436
...</pre>
So we see that the sequence starting with 689 converges to, and continues with the same numbers as that for 196. Because of this we can further split the Lychrel numbers into true '''Seed''' Lychrel number candidates, and '''Related''' numbers that produce no palindromes but have integers in their sequence seen as part of the sequence generated from a lower Lychrel number.
 
 
;Task:
* &nbsp; Find the number of seed Lychrel number candidates and related numbers for n in the range 1..10000 inclusive. (With that iteration limit of 500).
* &nbsp; Print the number of seed Lychrels found; the actual seed Lychrels; and just the ''number'' of relateds found.
* &nbsp; Print any seed Lychrel or related number that is itself a palindrome.
 
<br>
Line 54 ⟶ 68:
 
;References:
* &nbsp; [https://www.youtube.com/watch?v=bN8PE3eljdA What's special about 196?] Numberphile video.
* &nbsp; [http://oeis.org/A023108 A023108] Positive integers which apparently never result in a palindrome under repeated applications of the function f(x) = x + (x with digits reversed).
* &nbsp; [http://mathoverflow.net/questions/117104/status-of-the-196-conjecture/117277#117277 Status of the 196 conjecture?] Mathoverflow.
<br><br>