Private Sub FormInVB_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
Dim nLoop As Integer = 1
While (nLoop < 501)
If (CheckTail(nLoop, nLoop * nLoop)) Then
Debug.WriteLine(nLoop.ToString() + " : " + (nLoop * nLoop).ToString())
End If
nLoop = nLoop + 1
End While
End Sub
Private Function CheckTail(ByVal num1 As Integer, ByVal num2 As Integer) As Boolean
If (num1 = 0) Then
Return True
End If
If ((num1 Mod 10) = (num2 Mod 10)) Then
Return ((True) And (CheckTail(Decimal.Floor(num1 / 10), Decimal.Floor(num2 / 10))))
Else
Return False
End If
End Function