文员文件归档管理:用VB企业版6.0怎么编写求n的阶乘的一个程序?

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/09 06:06:34

作一个阶乘的函数:
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