Removing prime factor checking from brute_force algorithm