【程序代码vb】计算s=1/1+2/91*20+3/(1*2*3)+...+n/(1*2*...*n)的值(结果精确到0.00001)
问题描述:
【程序代码vb】计算s=1/1+2/91*20+3/(1*2*3)+...+n/(1*2*...*n)的值(结果精确到0.00001)
答
Private Sub Command1_Click()
Dim s As Double, i As Integer, t As Double
n = Val(InputBox("N="))
s = 1 '+ 2 / 91
t = 1
For i = 3 To n
t = t * (i - 1)
s = s + 1 / t
Next i
Print Format(s, "0.00000")
End Sub