王美虹西游记演的谁:用VB企业版6.0怎么编写求n的阶乘的一个程序?

来源:百度文库 编辑:高校问答 时间:2024/05/06 01:30:38

作一个阶乘的函数:
function factor(byval n as long) as long
s = 1;
for i = 1 to n
s = s * i
next i
factor=s
end function

调用此函数:(例:求100的阶乘,当然,你也可以是其他值。)

private sub command1_click()
print factor(100)
end sub

s = 1;
for i = 1 to n
s = s * i
next i
print s