设计求数列s=1+1/3+(-1/5)+1/7+1/9+(-1/11)+...前n(n>=1)项和的算法VB编程,用for next i 循环体编

问题描述:

设计求数列s=1+1/3+(-1/5)+1/7+1/9+(-1/11)+...前n(n>=1)项和的算法VB编程,用for next i 循环体编
用循环+选择结构,不要用floop float ftemp 之类的

Private Sub Command1_Click()Dim n As LongDim i As LongDim sum As Doublen = Val(Text1.Text)sum = 1#For i = 2 To n'sum = sum + (-1) ^ i * 1 / (2 * (i - 1) + 1)If 2 * Int(i / 2) = i Thensum = sum + 1 / (...