How to write Perfect number program code in vb.net using for loop and next
Dim sum As Integer = 0
Dim i As Integer
For i = 1 To Convert.ToInt16(TextBox1.Text) - 1
If (Convert.ToInt16(TextBox1.Text) Mod i = 0) Then
sum += i
End If
Next
If sum = Convert.ToInt16(TextBox1.Text) Then
MsgBox("It is perfect no")
Else
MsgBox("It is no perfect no")
End If
Dim sum As Integer = 0
Dim i As Integer
For i = 1 To Convert.ToInt16(TextBox1.Text) - 1
If (Convert.ToInt16(TextBox1.Text) Mod i = 0) Then
sum += i
End If
Next
If sum = Convert.ToInt16(TextBox1.Text) Then
MsgBox("It is perfect no")
Else
MsgBox("It is no perfect no")
End If
0 comments: