已知S=1+2+3+...+N,找出最大的整数N,使得S<3000.编写程序解决这个问题.

2024-12-21 10:00:25
推荐回答(1个)
回答1:

Dim total as Integer
total = 0
index = 1
N1 = 3000
N = 0
For index = 1 to N1
total = total + index
If total > 3000 Then
N = index
index = N1
End If
next