updated with new prime_factor algorithm