Project Euler #5 - Why won't this while loop finish? : <p>If I change the code line "num++" to "num+=2520", the code runs fine and returns the correct answer, but I'd like to know why it doesn't run as is, primarily because I didn't think of the fact that the number must be a multiple at 2520 before looking the answer up, and I don't see why my own code isn't correctly giving the answer without that change. To me, it seems correct. Unfortunately, the while loop never ends. </p>

<p>My guess is it has something to do with how long the correct number is (232792560), because if I lower the requirements even a little bit (from 9 to 8, per se), the while loop manages to finish.</p>

<pre><code>    long long int num = 1;
    int div_counter = 1;
    bool check = false;

while(!check)
{
    for(int i = 2; i &lt; 21; i++)
    {
       if(num % i == 0)
       {
           div_counter++;
       }
    }
    if(div_counter == 20)
    {
        check = true;
    }
    else
    {
        num++;
        div_counter = 0;
    }
}

return num;
</code></pre>
