用do...loop语句求sum=1+1+2+3+5+8+13+........+144的和
答案:2 悬赏:80 手机版
解决时间 2021-04-28 04:51
- 提问者网友:像風在裏
- 2021-04-27 08:19
用do...loop语句求sum=1+1+2+3+5+8+13+........+144的和
最佳答案
- 五星知识达人网友:孤独的牧羊人
- 2021-04-27 08:26
dim he as long,n as long
he=0
n=1
do
he=he+n
n=n+1
loop untill n>144
msgbox "累加和是:" & he
he=0
n=1
do
he=he+n
n=n+1
loop untill n>144
msgbox "累加和是:" & he
全部回答
- 1楼网友:轻熟杀无赦
- 2021-04-27 08:58
Private Sub Command1_Click()
Dim sumvalue As Long
Dim k As Long
Dim k2 As Long
k = 1
k2 = 1
sumvalue = k + k2
Dim tmp As Long
Do
tmp = k + k2
k = k2
k2 = tmp
If tmp > 144 Then
Exit Do
End If
sumvalue = sumvalue + k2
Loop
MsgBox sumvalue
End Sub
Dim sumvalue As Long
Dim k As Long
Dim k2 As Long
k = 1
k2 = 1
sumvalue = k + k2
Dim tmp As Long
Do
tmp = k + k2
k = k2
k2 = tmp
If tmp > 144 Then
Exit Do
End If
sumvalue = sumvalue + k2
Loop
MsgBox sumvalue
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯