You are on the Home/Other Tutorials/Project Euler/Problem 4 page
Web This Site

Project Euler - Problem 4

More about Project Euler.

Problem description

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99.

Find the largest palindrome made from the product of two 3-digit numbers.


Nothing fancy, though I suspect there is some pattern to palindromes that could have been leveraged.  But, given the small size of the problem...
Sub Euler004()
    Dim Rslt As Long, Nbr1 As Long, Nbr2 As Long, ProcTime As Single
    ProcTime = Timer
    For Nbr1 = 100 To 999
        For Nbr2 = 100 To 999
            Dim OneRslt As Long
            OneRslt = Nbr1 * Nbr2
            If StrReverse(OneRslt) = OneRslt Then Rslt = Max(Rslt, OneRslt)
            Next Nbr2
        Next Nbr1
    Debug.Print Rslt, Timer - ProcTime
    End Sub