使用 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