Module PerfectNum Sub Main() Dim n, p, r, sum As Integer Console.Write("Enter a number: ") n = CInt(Console.ReadLine()) p = 1 sum = 0 While p <= n \ 2 r = n Mod p If r = 0 Then sum += p End If p += 1 End While If sum = n Then Console.WriteLine(n.ToString + " is a Perfect Number") Else Console.WriteLine(n.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 the number is a Perfect Number or not
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment