Function yys(num As Long) As Boolean'判断一个数是否是盈余数
If num < facSum(num) Then
yys = True'盈余数
Else
yys = False'不是盈余数
End If
End Function
Function facSum(num As Long) As Long'求一个数的因子和
Dim fac As Long
facSum = 1
For fac = 2 To Sqr(num)
If num Mod fac = 0 Then
Debug.Print fac, num / fac
facSum = facSum + fac
facSum = facSum + num / fac * IIf(fac = num / fac, 0, 1) '如果num是平方数,则sum的平方根只加1次。
End If
Next fac
End Function没有图,不好做界面。给出你求因子和及判断是否是盈余数的两个函数。