VB中求1/2+2/3+3/4+4/5+……前50项之和(保留两位小数)的代码

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/12 08:41:19
VB中求1/2+2/3+3/4+4/5+……前50项之和(保留两位小数)的代码

VB中求1/2+2/3+3/4+4/5+……前50项之和(保留两位小数)的代码
VB中求1/2+2/3+3/4+4/5+……前50项之和(保留两位小数)的代码

VB中求1/2+2/3+3/4+4/5+……前50项之和(保留两位小数)的代码
dim i as integer
dim s as single

for i=1 to 50
    s=s+i/(i+1)
next
s=format(s,"0.00")
msgbox "和是:" & s