用VB计算 S=1+1/2+1/4+1/7+1/11+1/16+1/22+1/29+…当i项值
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/16 16:50:59
用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
用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