VB编程求解:1!+2!+...+n!>10000时n的最小值。单击窗体,在窗体上输出n的值。用循环嵌套
展开全部
这个程序用单重循环就可以实现的。
何必要用二重循环呢?
Private Sub Command1_Click()
s = 0
i = 0
t = 1
While s <= 10000
i = i + 1
t = t * i
s = s + t
Wend
Print "1!+2!+3!+...+"; Trim(Str(i)); "!="; s
End Sub
非要用二重循环的话:
Private Sub Command1_Click()
s = 0
i = 0
While s <= 10000
t = 1
i = i + 1
For j = 1 To i
t = t * j
Next j
s = s + t
Wend
Print "1!+2!+3!+...+"; Trim(Str(i)); "!="; s
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询