******************************************************************
判断完全数
Private Sub Command1_Click()
Dim X, I, Sum As Long
X = CLng(InputBox("输入一个整数"))
For I = 1 To X - 1
If X Mod I = 0 Then Sum = Sum + I
Next
MsgBox IIf((Sum = X), "是完全数", "不是完全数")
End Sub
Option Explicit
Private Sub form_Click()
Dim a&(), i&, j&, k&, m&, s&, t&
For i = 2 To 10000
Erase a
ReDim a(0)
a(0) = 1
s = 1
For j = 2 To Int(Sqr(i))
m = i Mod j
If m = 0 Then
ReDim Preserve a(UBound(a) + 1)
a(UBound(a)) = j
s = s + j
t = i \ j
If t > j Then
ReDim Preserve a(UBound(a) + 1)
a(UBound(a)) = t
s = s + t
End If
End If
Next
If s = i Then Print i
Next
End Sub
完全数是啥?网上先看看定义,应该有他自己的规则吧