用VB计算 S=1+1/2+1/4+1/7+1/11+1/16+1/22+1/29+…当i项值
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/31 10:57:05
![用VB计算 S=1+1/2+1/4+1/7+1/11+1/16+1/22+1/29+…当i项值](/uploads/image/z/1142583-15-3.jpg?t=%E7%94%A8VB%E8%AE%A1%E7%AE%97+S%3D1%2B1%2F2%2B1%2F4%2B1%2F7%2B1%2F11%2B1%2F16%2B1%2F22%2B1%2F29%2B%E2%80%A6%E5%BD%93i%E9%A1%B9%E5%80%BC)
x){>eEӋulkmo&@lĆ C3(HRQò{'g\i"}
M/+2KRKssRs254\2sr*Px6uV D+HߤZ @lU1k(
2TpWIU(V*3PS5Q id)Qeh||ӝ+A%5$"4 C {ysygHbNY^N2%P$فb
用VB计算 S=1+1/2+1/4+1/7+1/11+1/16+1/22+1/29+…当i项值
用VB计算 S=1+1/2+1/4+1/7+1/11+1/16+1/22+1/29+…当i项值
用VB计算 S=1+1/2+1/4+1/7+1/11+1/16+1/22+1/29+…当i项值
Private Sub Command1_Click() Dim m As Integer,n As Integer,s,result 'm为分母变量,n为位置变量,s为数值变量,result为和的变量 m = 1:n = 0:s = 1 / m:result = 0 + 1 / 1 Do While s >= 10 ^ -4 n = n + 1 m = m + n s = 1 / m result = result + s Loop MsgBox "S=1+1/2+1/4+1/7+1/11+1/16+1/22+1/29+… " & vbCrLf & "运算结果为:" & result,vbOKOnly,"运算结果" End Sub