what is the factorial of a number in cpp coding ??
Answers
Answered by
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);
}
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
Math,
7 months ago
Physics,
7 months ago
Political Science,
7 months ago
Social Sciences,
1 year ago
Math,
1 year ago
English,
1 year ago
Hindi,
1 year ago