To begin looking at SPU assembly language, I will enter in a simple program for calculating the factorial of a 32-bit number using a recursive algorithm.
在开始介绍 SPU 汇编语言之前,先来看一个通过递归算法计算 32 位数的阶乘的简单程序。
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)。
The factorial of a number is computed as that number times all of the Numbers below it up to and including 1.
计算某个数的阶乘就是用那个数去乘包括1在内的所有比它小的数。
应用推荐