求1000以内的所有完数vb,以每行五个输出到窗体上
1个回答
展开全部
其实1000以内的完数才3个。
Private Sub Command1_Click()
Dim i As Integer
For i = 1 To 1000
If i = yinzihe(i) Then Print i,:n=n+1
if n mod 5=0 then Print
Next i
Print
End Sub
Function yinzihe(x As Integer) As Integer
s = 0
For i = 1 To x \ 2
If x Mod i = 0 Then s = s + i
Next i
yinzihe = s
End Function
Private Sub Command1_Click()
Dim i As Integer
For i = 1 To 1000
If i = yinzihe(i) Then Print i,:n=n+1
if n mod 5=0 then Print
Next i
End Sub
Function yinzihe(x As Integer) As Integer
s = 0
For i = 1 To x \ 2
If x Mod i = 0 Then s = s + i
Next i
yinzihe = s
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询