vb 判断一个数是不是完数

2024-12-30 17:25:54
推荐回答(1个)
回答1:

Private Sub Command1_Click()

For i = 2 To 1000

Sum = 0

For j = 1 To i \ 2

If i Mod j = 0 Then

Sum = Sum + j

End If

Next j

If Sum = i Then Print i

Next i

End Sub