Largest Prime Factor- C++
<p>I'm trying to find the largest prime factor of the number 600851475143. My code works for smaller numbers that I test (below 100). However when confronted with 600851475143, it returns 4370432, definitely not prime. Any ideas what could be wrong with my code?</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;time.h&gt;
#include &lt;math.h&gt;

using namespace std;

int main()
{

int num;
int largest;
int count;

cout&lt;&lt;"Please enter a number to have its Largest Prime Factor found"&lt;&lt;endl;
cin&gt;&gt;num;
num = 600851475143;

for (int factor = 1; factor &lt;= num; factor++)
{
    if (num % factor == 0)
    {
        count = 0;
        for (int primetest=2; count == 0 &amp;&amp; factor &gt; primetest ; primetest++) 
        {
            if (factor % primetest == 0)
            count ++;    
            //endif
        }
        if (count == 0)
        largest = factor;
        //endif
    }       

}//endif
cout&lt;&lt;largest&lt;&lt;endl;
system("PAUSE");
}
</code></pre>
