Is there any flaw in the logic of this problem? The problem is find the number of factors of (N!)^2.

This is the code, I wrote:

int prime[]={//list of primes &lt;(10^6)};
int num_fac_of_factorial(int n, int x)
{
    int p=x, z=0;
    while(n/p&gt;0)
    {
        z+=n/p;
        p*=x;
    }
    return z;
}

int count=78498;   //Count of prime numbers &lt;10^6

int main()
{
    int n, x, first=0, m=1000007;
    long long sol=1;
    scanf("%d", &amp;n);

    for(int i=0; prime[i]&lt;=n &amp;&amp; i&lt;count; i++)
    {
        x=num_fac_of_factorial(n, prime[i]);
        x=2*x+1;
        sol=(sol*x)%m;
    }
    sol%=m;
    printf("%d\n", sol);
}
There's no flaw in the logic, just a couple of implementation errors. And if e.g. 1/10 + 1/15 = 1/6 and 1/15 + 1/10 = 1/6 shall not be counted as different solutions but as one, then of course you need (1 + number of divisors)/2.

Here

for(int i=0; prime[i]&lt;=n &amp;&amp; i&lt;count; i++)


you ought to check i &lt; count before accessing prime[i]. If n &gt; 999983, you will try to access prime[78498], which is undefined behaviour.

And - assuming that int is as usual 32 bits (or 36, wouldn't apply to 64-bit ints, however) - here

int num_fac_of_factorial(int n, int x)
{
    int p=x, z=0;
    while(n/p&gt;0)
    {
        z+=n/p;
        p*=x;
    }
    return z;
}


you have overflow for large enough primes x (typically &gt; 46340) when calculating x*x, which is also undefined behaviour. And with the not uncommon wrap-around for int overflow, that will cause wrong results for n &gt;= 65537. Replace the while loop with

do {
    n /= x;
    z += n;
while(n &gt; 0);


to avoid the overflow.