Imports System
' Armstrong = a number that equals the sum of its digits,
' each raised to a power of the number of digits
' For example 153, it's an Armstrong number because 1^3 + 5^3 + 3^3 = 153
Public Class Program
Public Shared Function armstrong(ByVal n As Integer) As Boolean
Dim reminder As Integer = 0, sum As Integer = 0, total_digits As Integer = Math.Floor(Math.Log10(n) + 1)
Dim temp As Integer = n
While temp > 0
reminder = temp Mod 10
sum += CInt(Math.Pow(reminder, total_digits))
temp = temp \ 10
End While
If sum = n Then
Return True
End If
Return False
End Function
Public Shared Sub Main(ByVal args As String())
For i As Integer = 100 To 999 step 1
If armstrong(i) Then
Console.Write(i & ", ")
End If
Next
End Sub
End Class
' run:
'
' 153, 370, 371, 407,
'