VB编程求sum=1+1⼀2+1⼀3+...+1⼀n

2024年11月17日 12:25
有3个网友回答
网友(1):

Private Sub Form_Click()
Dim i As Integer
Dim sum As Double
Dim t As Double
sum = 0
i = 1
t = 1 / i
Do While t > 0.0001
sum = sum + t
i = i + 1
t = 1 / i
Loop
Debug.Print "i="; i; "sum="; sum

End Sub

网友(2):

一楼说的好,你倒是给答案啊
主体:
double n=1,sum=0
do
{
sum=sum+1/n
n=n+1
}
while(1/n>0.0001)
loop
print n

网友(3):

简单、