Am I doing something wrong with my simple factorial calculator C++ program?
<p>Half an hour ago, I made a simple factorial calculator that takes non-zero integers as inputs. After testing it for some values, I noticed that it only work properly until 12!.</p>

<p>I haven't been programming for some months now, and still am a beginner to be honest. I decided to use recursion so I could get back in to "programming mode" faster (my preference).</p>

<p>I checked and modified it for almost an hour now. I don't really know what is wrong with my algorithm.</p>

<p>This is my code:</p>

<pre><code>#include &lt;iostream&gt;

using namespace std;

int factorial(int);

int main()
{
    int usrInput = 0;   //initialize input variable
    cout &lt;&lt; "Please input the factorial you want to calculate: ";
    cin &gt;&gt; usrInput;
    while(usrInput &lt; 1)
    {
        cout &lt;&lt; "Please input a valid number: ";
        cin &gt;&gt; usrInput;
    } //end while
    cout &lt;&lt; "\nAnswer: " &lt;&lt; factorial(usrInput) &lt;&lt; '\n';
    return 0;
}

int factorial(int n)
{
    int product = n;
    if(n &lt; 2)
        product = 1;
    else
    {
        product *= factorial(n-1);
    cout &lt;&lt; "\n" &lt;&lt; product; //debugging line
    } //end if else
    return product;
}
</code></pre>
