【VB】用函数过程求表达式1+1/2+1/3+1/4+…+1/n的和.

来源:学生作业学帮网 编辑:学帮网 时间:2024/07/02 23:44:39

【VB】用函数过程求表达式1+1/2+1/3+1/4+…+1/n的和.

Function Sum1(ByVal n As Intger) As Double
Dim i As Integer
Sum1=0
for i =1 to n
Sum1=Sum1+ 1/i
next i
End Function