Lychrel numbers: Difference between revisions

m
→‎{{Header|REXX}}: allowed the specification for the LIMIT, added/changed whitespace and comments.
(→‎{{header|Haskell}}: make it infinite list)
m (→‎{{Header|REXX}}: allowed the specification for the LIMIT, added/changed whitespace and comments.)
Line 2,953:
=={{Header|REXX}}==
<lang rexx>/*REXX program finds and displays Lychrel numbers, related numbers, and palindromes. */
numeric digits 250parse arg high limit . /*ensureobtain enoughoptional decimalargument digitsfrom forthe addsCL.*/
parseif arg high='' . | high=="," then high= 10000 /*obtainNot specified? optional argumentThen fromuse the CLdefault.*/
if highlimit='' | highlimit=="," then highlimit= 10000 500 /*Not specified? Then use the default.*/
limit= 500 numeric digits limit % 2 /*limit:ensure enough numberdecimal ofdigits Lychrelfor iterations.adds*/
T.= 0; @.= T.; #.=@.; w= length(high) /*W: is used for formatting numbers. */
$= /*the list of Lychrel numbers. */
do j=1 for high; call Lychrel j /*find the Lychrel numbers. */
end /*j*/
p=; R= R= /*P: list of palindromes; R: related #s*/
do k=1 for high
if #.k then $= $ k /*build a list of Lychrel numbers. */
if T.k then R= R k /* " " " " " related nums.*/
if T.k & k==reverse(k) then p= p k /* " " " " " palindromes. */
end /*k*/
 
say 'Found in the range 1 to ' high " (limiting searches to " limit ' steps):'
say
say right( words($) , w) 'Lychrel numbers:' $
say right( words(R) - words($), w) 'Lychrel related numbers.'
say right( words(p) , w) 'Lychrel palindromes:' p
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/