Now, let's return to the factorial function.
现在,让我们回到阶乘函数上来。
This limits greatly the possible range of your factorial function.
这极大地限制了阶乘函数的可能范围。
Therefore, you need to pass it as the first (and only) parameter to the factorial function.
因而,需要将其作为第一个(也是惟一一个)参数传递给factorial函数。
Don't be taken aback by the size of the code — it's mostly comments and declarations (the factorial function itself only has 16 instructions).
这段代码看起来比较多,但您也无需望而却步,因为其中大部分都是注释和声明(阶乘函数本身只有16个指令)。
The best way to see why stacks are needed is to look at recursive functions. For simplicity, let's look at the recursive implementation of the factorial function.
了解为什么需要堆栈的最好方法是查看递归函数的情况。
This functionality works well as a recursive application, as shown in the sample factorial function in Listing 4.
这个功能作为递归应用程序工作良好,如清单4中的样本阶乘函数所示。
Since factorials of numbers less than 1 don't make any sense, we stop at the number 1 and return the factorial of 1 (which is 1). Therefore, the real factorial function will look like this
由于小于1的数的阶乘没有任何意义,所以我们在计算到数字 1 的时候停止,并返回 1的阶乘(即 1)。
Since factorials of numbers less than 1 don't make any sense, we stop at the number 1 and return the factorial of 1 (which is 1). Therefore, the real factorial function will look like this
由于小于1的数的阶乘没有任何意义,所以我们在计算到数字 1 的时候停止,并返回 1的阶乘(即 1)。
应用推荐