Heeeello!
I'm trying to find a way how to compute a factorial of any given number.
the factorial of a positive integer is defined as follows:
n! = n(n-1)(n-2)(n-3).....
what I'm trying to do here is to find a way so that the program will know how many steps it need to do to get to (1).
example) I want to compute the factorial of the number 6.
6! = 6(5)(4)(3)(2)(1) = 720
I was just trying something like:
ofc, this will not work but.. yeah, a little help please ^^Code:#include <iostream>
using namespace std;
int main()
{
int n = 0;
int n1;
cout << "enter a positive integer and the compute the factorial of: ";
cin >> n;
n1 = n(n-1)(n-2)(n-3);
cout << n1;
_getch();
return 0;
}

