Home > Back-end >  Code:
Code:

Time:09-27

Write a program, using a recursive method to calculate n!

CodePudding user response:

What are the requirements for???

CodePudding user response:

 
#include
using namespace std;
Int fun (int n)//you can put the fun into arbitrary function name, here I write letters before the function directly
{
If (n==1) {
return 1;//termination, no longer recursive
}
Return fun (n - 1) * n;//n times of factorial n - 1
}
Int main ()
{
int n;
Cin> n;
coutreturn 0;
}

This is to use recursive, pay attention to the input number can't be too big