使用 Nilakantha 级数可用于计算 Pi(π) 的无穷级数,它的计算机结果比莱布尼茨公式更快地接近 Pi(π)的近似值。
有下列代码,通过前n项的计算,求Pi近似值,下列选项中正确的是( )
Private Sub Command2_Click( )
Dim f As Integer, i As Long, n As Long
Dim pi As Double, s As Double
s = 0: n = Val(Text1.Text)
For i = 2 To 2*n ①
s = s + ②
Next i
pi = 3 + s * 4
Label2.Caption = Str(pi)
End Sub
- A、① step 1 ② (-1)^(i\2+1) / (i * (i + 1) * (i + 2))
- B、① step 1 ② (-1)^(i\2) / (i * (i + 1) * (i + 2))
- C、① step 2 ② (-1)^(i\2+1) /(i * (i + 1) * (i + 2))
- D、① step 2 ② (-1)^(i\2) / (i * (i + 1) * (i + 2))