Pages

Search This Blog

Armstrong Number Generation


Module ArmsNum_Generation

    Sub Main()
        Dim r, sum, t, max, min As Integer

        Console.Write("Enter a minimum number= ")
        min = CInt(Console.ReadLine())
        Console.Write("Enter a maximum number= ")
        max = CInt(Console.ReadLine())
        Console.WriteLine("Armstrong Numbers are:- ")
        While min <= max
            t = min
            sum = 0
            While t <> 0

                r = t Mod 10
                sum += Math.Pow(r, 3)
                t = t \ 10
            End While

            If sum = min Then

                Console.WriteLine(min.ToString())
            End If
            min += 1

        End While
        Console.ReadLine()
    End Sub

End Module

No comments:

Post a Comment