Some theory:
A number is prime if it cant be divided by any prime number less than or equal to its square root.
2 is a prime number.
So the largest prime factor of a number is the number itself (if it is prime) or a value less than or equal to its square root.
Therefore you only need all the primes below sqrt(600851475143) = 775147
If you use dynamic programming, can speed up.