var factorial:Function = function(x:uint)
{
if(x==0)
return 1;
else
return(x*arguments.callee(x-1));
};
trace(factorial(5));
主要问题是这里:
arguments.callee 返回的是当前函数的引用.
arguments.callee在这里也就是factorial;不停的调用自己.和递归一样.
var factorial:Function = function(x:uint)
{
if(x==0)
return 1;
else
return(x*arguments.callee(x-1));
};
trace(factorial(5));