编写一个函数jiecheng,用以求解某个整数的阶乘,然后通过函数调用求出1+2!+3!+4!+5
使用递归方法:
PrivateSubCommand1_Click()DimiAsInteger
DimsumAsLong
sum=0
Fori=1To5
sum=sum+JieCheng(i)
Next
Printsum
EndSub
PrivateFunctionJieCheng(iAsInteger)AsLong
SelectCasei
CaseIs<=0
JieCheng=0
Case1
JieCheng=1
CaseElse
JieCheng=JieCheng(i-1)*i
EndSelect
EndFunction
多重随机标签