试用VB程序语言写出主要程序段:求S=1!+2!+3!+……+99!的值

如题所述

第1个回答  2010-08-19
主程序:
Private Sub Form_Click()
For i = 1 To 99
s = s + t(i)
Next i
Print "1!+2!+3!+....+99!="; s
End Sub
function函数(子程序)
Public Function t(ByVal x As Integer)
n = 1
For j = 1 To x
n = n * j
Next j
t = n
End Function
第2个回答  2010-08-19
Private Sub Command1_Click()
Dim S As Double, jc As Double
jc = 1
For i = 1 To 99
jc = jc * i
S = S + jc
Next
Print "S="; S
End Sub本回答被提问者采纳
第3个回答  2010-08-19
dim s as long
dim i as integer
private function fn(dim n as integer) '递归函数,求n!
if n=1 then
fn=1
else
fn=fn(n-1)
end if
end function

Private Sub Form_Load()
for i=1 to 99
s=s+fn(i)
next i
End Sub
相似回答