How to find the largest prime factor of 600851475143 in C? [duplicate]

Looping up to 600 billion will take forever — not just a long time, but impossible because it exceeds what can be stored in an int (usually up to 2^31-1 these days, but could be as small as 2^15-1 according to the C standard).

What you need is a smarter algorithm. Rather than giving you the solution verbatim, I suggest that you look at existing answers and work out a solution in C by yourself.

Leave a Comment