求圆周率∏的近似值.公式为= 1-+-…+(-1)(n+1)×,直到最后一项的绝对值小于0.000001 为止

问题描述:

求圆周率∏的近似值.公式为= 1-+-…+(-1)(n+1)×,直到最后一项的绝对值小于0.000001 为止

Private Sub Form_Click()Dim pi As DoubleDim n As Longn = 1Dopi = pi + 4 * ((-1) ^ (n - 1) * (1 / (2 * n - 1)))n = n + 1Loop Until 1 / (2 * n - 1)