求VB的100阶乘代码

来源:百度知道 编辑:UC知道 时间:2024/05/21 06:19:13
急求

楼上,long会溢出的

debug.print Factorial(100)

Private Function Factorial(ByVal parameter As Integer) As Double
If parameter < 2 Then Return 1
Factorial = parameter * Factorial(parameter - 1)
End Function

dim n as long
n=1
for i=1 to 100
n=n*i
next

用递归方法

VB课本上有 自己找找就有了