展开全部
Private Sub Command1_Click()
Print "1000以内的所有完数为:";
Dim b As Double
Dim i As Double, j As Double, k As Double
For i = 2 To 10000
k = 0
For j = 2 To Sqr(i)
If i Mod j = 0 Then k = k + i / j + j
Next j
k = k + 1
If k = i Then
Print
Print CStr(i) & "=";
fenjie (i)
End If
DoEvents
Next i
End Sub
Function fenjie(n As Double)
Dim j As Double
For j = 1 To n \ 2
If n / j = n \ j Then
Print CStr(j) & IIf(j = n \ 2, "", "+");
End If
Next j
End Function
Print "1000以内的所有完数为:";
Dim b As Double
Dim i As Double, j As Double, k As Double
For i = 2 To 10000
k = 0
For j = 2 To Sqr(i)
If i Mod j = 0 Then k = k + i / j + j
Next j
k = k + 1
If k = i Then
Print CStr(i) & "=";
fenjie (i)
End If
DoEvents
Next i
End Sub
Function fenjie(n As Double)
Dim j As Double
For j = 1 To n \ 2
If n / j = n \ j Then
Print CStr(j) & IIf(j = n \ 2, "", "+");
End If
Next j
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询