Largest palindrome product

From Rosetta Code
Revision as of 06:40, 3 November 2021 by CalmoSoft (talk | contribs) (Created page with "{{Draft task}} ;Task: <br>Task description is taken from Project Euler (https://projecteuler.net/problem=4) <br>A palindromic number reads the same both ways. The largest pal...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Largest palindrome product is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task


Task description is taken from Project Euler (https://projecteuler.net/problem=4)
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.

Ring

<lang ring> load "stdlib.ring" see "working..." + nl

prodOld = 0 limitStart = 100 limitEnd = 999

for n = limitStart to limitEnd

   for m = limitStart to limitEnd
       prodNew = n*m
       if prodNew > prodOld and palindrome(string(prodNew))
          prodOld = prodNew
          first = n
          second = m
       ok
   next

next

see "The largest palindrome is:" + nl see "" + first + " * " + second + " = " + prodOld + nl see "done..." + nl </lang>

Output:
working...
The largest palindrome is:
913 * 993 = 906609
done...