VB编程求1000之内的所有完数

2024-11-27 07:25:05
推荐回答(2个)
回答1:

Private Sub Command1_Click()
For n = 1 To 1000
s = "" '这一句要加上
Sum = 0
For i = 1 To n / 2
If n Mod i = 0 Then
Sum = Sum + i
s = s + Str(i) + "+"
End If
Next i
If n = Sum Then
s = Left(s, Len(s) - 1)
Picture1.Print s; "="; n '这里 Picture1是图片框的名字
End If
Next n
End Sub

回答2:

什么叫做“完数”?