+ 1
Factorial ??
code of how calculate the factorial
4 Answers
+ 1
Rain, that's C++, not C#.
0
#include <iostream>
using namespace std;
int factorial(int num){
if(num > 1){
num *= factorial(num - 1);
} else {
return num;
}
}
int main() {
int num;
int sum = 0;
cout << "Input number to get factorial of: ";
cin >> num;
cout << num << endl;
sum = factorial(num);
cout << "The factorial of " << num << " is "<<sum;
}
0
Check out my codes. Its is in java, but
0
@1of3: Oh, I didn't notice the tag, I just thought in general