又一个ASP编程难题

来源:百度知道 编辑:UC知道 时间:2024/05/20 16:35:23
1!+2!+3!+………+10!=
这个等于多少,在ASP中如何用代码算出来 。

<%
dim i,result
result=0

for i=1 to 10
result=result+fact(i)
next

response.write result
%>

fact就是求阶乘,不知道ASP里面现在有没有……
自己也可以编一个:
<%
function factdiy(in_i)

if in_i=0 then
returen 1
end if

dim i,result
result=1

for i=1 to in_i
result=result*i
next

return result

end function

'这样的话,上述调用的fact(i)就要改成factdiy(i)了。
%>

N多年没用了,没调试过,仅提供一个思路,自己试试吧……