faster way of finding largest prime factor