Project Euler 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.
My solution was a quick brute force attack done while I was eating lunch at work.
Public Sub Palindrome()
Dim iMax As Integer = 999
Dim iX, iY, iProduct, iStart, iEnd, iLargest As Integer
iLargest = 0
Dim bFound As Boolean = False
For iX = 100 To iMax
For iY = 100 To iMax
iProduct = iX * iY
Dim sProduct As String = iProduct.ToString()
iStart = 0
iEnd = sProduct.Length - 1
Dim bStop As Boolean = False
While (iStart + 1 <= iEnd And bStop = False)
If (sProduct(iStart) <> sProduct(iEnd)) Then
bStop = True
End If
iStart = iStart + 1
iEnd = iEnd - 1
End While
If (bStop = False) Then
If (iProduct > iLargest) Then
iLargest = iProduct
End If
End If
Next
Next
Response.Write(iLargest.ToString())
End Sub