Guest User

Untitled

a guest
Nov 24th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.66 KB | None | 0 0
  1.  
  2.     Sub perfecto()
  3.         Dim ms As String = "Los perfectos numeros son"
  4.         Dim i, b, sumdiv As Integer
  5.        
  6.         sumdiv = 0
  7.         ListBox1.Items.Clear()
  8.  
  9.         For b = 0 To c - 1
  10.             n = Int(grid1.Rows(b).Cells(0).Value)
  11.             sumdiv = 0
  12.             For i = 1 To n - 1 'evaluamos el numero y sus divisores
  13.                 If (n Mod i) = 0 Then
  14.                     sumdiv = sumdiv + i
  15.                 End If
  16.             Next
  17.             If sumdiv = n Then
  18.                 With ListBox1
  19.                     .Items.Add(n)
  20.  
  21.                 End With
  22.                
  23.  
  24.             End If
  25.         Next
  26.        
  27.     End Sub
Add Comment
Please, Sign In to add comment