计算n!

  使用递归计算n的阶乘n!-LMLPHP

观察公式2可以直接使用递归求解

C++代码如下:

 #include <iostream>
using namespace std; unsigned func(unsigned n) {
if (n == ) return ;
else return func(n - )*n;
}
int main() {
unsigned n,x;
cin >> n;
x = func(n);
cout << x ;
return ;
}
05-29 01:06