'第4题
Private Sub Form_Click()
Dim n As Integer, x As Single
x = Val(InputBox("x=?"))
n = Val(InputBox("n=?"))
Print fe(n, x)
End Sub
Private Function fe(n%, x!) As Single
Dim jc As Long
jc = 1
fe = 1
For i = 1 To n
jc = jc * i
fe = fe + x ^ i / jc
Next i
End Function
'第5题
Private Sub Command1_Click()
Dim m As Integer
m = Val(InputBox("m=?"))
If wqs(m) Then
MsgBox m & "是完全数!"
Else
MsgBox m & "不是完全数!"
End If
End Sub
Private Function wqs(n%) As Boolean
Dim s As Integer
For i = 1 To n - 1
If n Mod i = 0 Then s = s + i
Next i
If s = n Then wqs = True
End Function
温馨提示:答案为网友推荐,仅供参考