Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub perfecto()
- Dim ms As String = "Los perfectos numeros son"
- Dim i, b, sumdiv As Integer
- sumdiv = 0
- ListBox1.Items.Clear()
- For b = 0 To c - 1
- n = Int(grid1.Rows(b).Cells(0).Value)
- sumdiv = 0
- For i = 1 To n - 1 'evaluamos el numero y sus divisores
- If (n Mod i) = 0 Then
- sumdiv = sumdiv + i
- End If
- Next
- If sumdiv = n Then
- With ListBox1
- .Items.Add(n)
- End With
- End If
- Next
- End Sub
Add Comment
Please, Sign In to add comment