I'm reading through "C++ without fear". You don't get answers for the exercises and I'm stuck on one so I can't look it up. I'm suppose to make a function that finds the factorial of a number. I'm probably looking over a simple way to do this, but I can't seem to think of any simple way to do it. So if anyone could help me that would be great.
usingnamespace std;
int factorial(int a);
main (){
int n=0;
cout << "Please enter your number: ";
cin >> n;
cout << "The factorial of " << n << "is: " << factorial(n);
system ("pause");
return 0;
}
int factorial(int a){
for (int i=1;i<=a;i++){
//I don't know what to put here to find the factorial, at least nothing simple.
}
return a;
}