Computer Science, asked by shanayamathur, 1 year ago

what is the factorial of a number in cpp coding ??

Answers

Answered by vice
2
#include <iostream>
using namespace std;
int n;
int factorial(int n) {
if (n==1) {
return 1;
}
else {
return n * factorial(n-1);
}
}

int main() {
cin>> n;
cout<<"The factorial of the number is\n";
cout<<n*factorial(n-1);
}
Similar questions