1-2/2!+3/3!-4/4!+…(-1)^n+1*n/n!编写vb程序

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/22 17:11:55
1-2/2!+3/3!-4/4!+…(-1)^n+1*n/n!编写vb程序1-2/2!+3/3!-4/4!+…(-1)^n+1*n/n!编写vb程序1-2/2!+3/3!-4/4!+…(-1)^n+1

1-2/2!+3/3!-4/4!+…(-1)^n+1*n/n!编写vb程序
1-2/2!+3/3!-4/4!+…(-1)^n+1*n/n!编写vb程序

1-2/2!+3/3!-4/4!+…(-1)^n+1*n/n!编写vb程序
Private Sub Command1_Click()
Dim n%,sum!,fact!
sum = 0
n = InputBox("输入n:","提示信息",1)
If n < 0 Then
MsgBox "数据有误!",48,"警告!"
End If
For i = 1 To n
fact = 1
For j = 1 To i
fact = fact * j
Next j
sum = sum + (-1) ^ (i + 1) * i / fact
Next i
Print sum
End Sub