I have a problem with a code attempting to do a factorial of a number. For numbers 12 and below, the code works fine, but when I do 13 and above it outputs the wrong number.
#include <iostream>
using namespace std;
int number;
int number2;
int main()
{
cout << "Enter a number to do a factorial of:\t";
cin >> number;
number2=number;
do
{
number=number-1;
number2=number2*number;
}while(number>1);
cout << "Your number is: ";
cout << number2;
cout << endl;
system("pause");
cout << endl;
}
Thanks in advance.