Module PerfectNum_ForLoop Sub main() Dim n, i, s, t As Integer Console.Write("Enter a Number: ") n = CInt(Console.ReadLine()) s = 0 t = n For i = 1 To n / 2 If n Mod i = 0 Then s += i End If Next If s = t Then Console.WriteLine(t.ToString + " is a Perfect Number") Else Console.WriteLine(t.ToString + " is NOT a Perfect Number") End If Console.ReadLine() End Sub End Module
Visual Basic dot net VB.net programming microsoft .net framework object oriented language network enabled technology visual basic 2005 IDE integrated development environment console application microsoft cre common runtime environment
Check whether a number is Perfect Number or not using For-loop
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment