vb编写程序,从键盘输入一个小于八的正整数n,求n+(n+1 )!+(n+2 )!......+9!

如题所述

第1个回答  2011-01-12
dim n,result as long
private sub form_load()
on error goto errorcommand
n=inputbox("请输入一个小于8的整数:","提示")
if n>=0 and n<8 then
result=n+(n+1)!+(n+2)!……+9! '此行不能省略,要写完整。
exit sub
end if
errorcommand:
msgbox "输入的不合法!将自动退出程序。"
end
end sub
第2个回答  2011-01-09
n大于4结果会溢出!!
Private Sub Form_Click()
Dim n, i, j As Integer
Dim t, s As Long
n = InputBox("请输入1个小于8的整数")
s = 0
For i = 0 To 9
t = 1
For j = 1 To n + i
t = t * j
Next j
s = s + t
Next i
Print s
End Sub本回答被提问者和网友采纳
相似回答
大家正在搜