vb求和,求sin(x)=x/1-x^3/3!+x^5/5!- …… (-1)^(n-1)* x^(2*n-1)/(2n-1)!感叹号是阶乘的意思Private Sub Form_Click()Dim x%,,i%,q%x = Val(InputBox("请输入X的值"))Do While t >= 10 ^ (-5)s = s + tn = n + 1For k = 1 To 2 * n - 1q = q * kNext kt = ((-1) ^ (n - 1)) * (x ^ (2 * n - 1)) \ qLoopPrint "s="; sEnd Sub当第n项的值小于10^-5时结束
问题描述:
vb求和,求sin(x)=x/1-x^3/3!+x^5/5!- …… (-1)^(n-1)* x^(2*n-1)/(2n-1)!感叹号是阶乘的意思
Private Sub Form_Click()
Dim x%,,i%,q%
x = Val(InputBox("请输入X的值"))
Do While t >= 10 ^ (-5)
s = s + t
n = n + 1
For k = 1 To 2 * n - 1
q = q * k
Next k
t = ((-1) ^ (n - 1)) * (x ^ (2 * n - 1)) \ q
Loop
Print "s="; s
End Sub
当第n项的值小于10^-5时结束
答