Is there any flaw in the logic of this problem?
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.