[Solved] Program doesn’t run, too much work? [closed]


The complexity of the program is huge – it would take forever to run. It is possibly valid, but the number of iterations in for loops is just enormous.

You are trying to run this loop:

for (unsigned __int64 i = 300851475143; i > 2; i--)

which alone is way too big for the program to finish quickly.

In addition to that, in prime() you’re running a second loop:

for (unsigned __int64 i = 2; i < para; i++)

which (since para is related to i in the outer loop) makes the complexity O(n^2)

solved Program doesn’t run, too much work? [closed]