Optimize largest prime factor algo.