用fact函数求阶乘求和的vb语言用过程法 +2!+3!+ +n!调用fact函数求阶乘之和

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/04 05:12:54
用fact函数求阶乘求和的vb语言用过程法 +2!+3!+ +n!调用fact函数求阶乘之和

用fact函数求阶乘求和的vb语言用过程法 +2!+3!+ +n!调用fact函数求阶乘之和
用fact函数求阶乘求和的vb语言用过程法 +2!+3!+ +n!调用fact函数求阶乘之和

用fact函数求阶乘求和的vb语言用过程法 +2!+3!+ +n!调用fact函数求阶乘之和
Option Explicit
Dim s As Integer
Private Sub Command1_Click()
Text2.Text = Str(fact(Val(Text1.Text)))
s = 0
End Sub
Private Function fact(n As Integer) As Integer
Dim i As Integer,j As Integer
j = 1
fact = 0
For i = 1 To n
j = j * i
s = s + j
Next i
fact = s
End Function