-- just recursively go through the list of primes to compute the factors of n
primeFactors n = factor n primes
  where factor n (p:ps)
          | p*p > n        = [n]
          | n `mod` p == 0 = p : factor (n `div` p) (p:ps)
          | otherwise      =     factor n ps

ans = last (primeFactors 600851475143)