Imports System
Imports Microsoft.VisualBasic
Public Module Module1
Public Sub Main()
dim m as integer = 0
dim x as integer = 0
dim counter as integer = 0
while counter < 8
m = cint(m + 1)
x = cint(m)
do
x = cstr(x)
x = cint(SumofSquares(x))
loop until x = 1 or x = 4
if x = 1 then
counter = counter + 1
Console.WriteLine(m)
end if
end while
End Sub
function SumofSquares(x as string) as string
dim digits as integer = x.length
dim sum as integer = 0
dim square as integer
for n = 1 to digits
square = cint(left(x,n-1))
square = square ^ 2
sum = sum + square
next n
return sum
end function
End Module