As part of Project Euler I have to find the largest palindrome made from the product of two 3-digit numbers.
I have created this code but when i3 gets to 909090 there is an error which states largest "Index was outside the bounds of the array." on the lineHere is my full code, I'm not sure exactly what is wrong?Code:If i3(0) = i3(5) And i3(1) = i3(4) And i3(2) = i3(3) Then
Also, i3 is a string because I couldn't work out how to go through an integer digit by digit?
Code:Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim i As Integer = 999 Dim i2 As Integer = 999 Dim i3 As String Dim found As Boolean = False Do Until found = True If i2 > 1 Then i2 = i2 - 1 Else : i2 = 999 i = i - 1 End If i3 = i * i2 If i3.Length = 5 Then If i3(0) = i3(5) And i3(1) = i3(4) And i3(2) = i3(3) Then found = True End If ElseIf i3.Length = 4 Then If i3(0) = i3(4) And i3(1) = i3(3) Then found = True End If End If Loop MsgBox(i3) End Sub End Class




Reply With Quote
