用vb求pi/4 = 1-1/3+1/5-1/7+...公式求pi的近似值,直到最后一项绝对值小于10-6为止
问题描述:
用vb求pi/4 = 1-1/3+1/5-1/7+...公式求pi的近似值,直到最后一项绝对值小于10-6为止
答
Private Sub Command1_Click()
a = 1
Do
n = n + 1
m = 2 * n - 1
s = s + a * 1 / m
a = -a
Loop Until Abs(1 / m) pi = 4 * s
Print "pi=" & pi
End Sub