How to resolve the algorithm Lychrel numbers step by step in the Phix programming language
How to resolve the algorithm Lychrel numbers step by step in the Phix programming language
Table of Contents
Problem Statement
The above recurrence relation when applied to most starting numbers n = 1, 2, ... terminates in a palindrome quite quickly.
If n0 = 12 we get And if n0 = 55 we get Notice that the check for a palindrome happens after 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. For the purposes of this task a Lychrel number is any starting number that does not form a palindrome within 500 (or more) iterations.
Any integer produced in the sequence of a Lychrel number is also a Lychrel number. 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: 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.
Show all output here.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Lychrel numbers step by step in the Phix programming language
Source code in the phix programming language
You may also check:How to resolve the algorithm ISBN13 check digit step by step in the Quackery programming language
You may also check:How to resolve the algorithm Strip control codes and extended characters from a string step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Hello world/Standard error step by step in the Forth programming language
You may also check:How to resolve the algorithm Call a function step by step in the COBOL programming language
You may also check:How to resolve the algorithm Subtractive generator step by step in the Wren programming language