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
温馨提示:答案为网友推荐,仅供参考