> 数学 >
用VB计算 S=1+1/2+1/4+1/7+1/11+1/16+1/22+1/29+…当i项值
人气:477 ℃ 时间:2020-01-29 09:59:05
解答
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
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版