c++ large numbers in factorial
<p>I am trying to make a program with the problem "Given a positive integer <strong>a</strong>, what is the minimum positive integer <strong>g</strong> such that <strong>g!</strong> is a multiple of the square of <strong>a!</strong>?</p>

<p>Sample Input</p>

<p>1 (test case)</p>

<p>4</p>

<p>Sample Output</p>

<p>8</p>

<p>Explanation:  8!=40320 is divisible by 4!^2=24^2=576. Furthermore, it is the smallest one because  7!=5040 is not divisible by 576.</p>

<p>The program is successful, but i'm having trouble when the input is larger than about 20. It wont output anything.</p>

<p>Any suggestions?</p>

<pre><code>#include &lt;cmath&gt;
#include &lt;cstdio&gt;
#include &lt;vector&gt;
#include &lt;iostream&gt;
#include &lt;algorithm&gt;
using namespace std;


int main() {
long long a,b,c=1,d,e=1,f=1,g=0,k;
cin&gt;&gt;a;
while(a&gt;0){
    cin&gt;&gt;b;
    g=0;
    e=1;
    c=1;
    f=1;
    for (long long i=1; i&lt;=b; i++){
        c=c*i;
    }
    d=c*c;
    for(long long j=1; e!=0; j++){
        f=f*j;
        g=g+2;
        e=f%d;
        if(c==e)
        cout&lt;&lt;g&lt;&lt;endl;
    }
    a--;
}
return 0;
</code></pre>

<p>}</p>