VB N的阶乘

来源:百度知道 编辑:UC知道 时间:2024/05/26 01:37:22
请用户在对话框中输入一个介于0到50之间的数,计算其阶乘的和并返回结果。

首席执行官的答案到37的时候就要溢出了
dim s as Double,n as long,i as long
n=text1.text
if n=0 then
print "0!"=1
end if
s=1
for i=1 to n
s=s*i
next i
print n;"!=";s

dim s as long,n as long,i as long
n=text1.text
if n=0 then
print "0!"=1
end if
s=1
for i=1 to n
s=s*i
next i
print n;"!=";s

a= text1.text
for i=2 to a
a=a*(a-1)
next
大概就是这样
不懂给我发消息