Quote Originally Posted by Caerulea View Post
I think prime numbers would be best if you are looking at factors. Maybe something like:
  1. Is the number divisible by prime p?
  2. If Yes: store p and ask about two again, If no:
  3. Is the next prime large than the number? If so: break. (There is probably a smaller end condition that could be used).
  4. Is the number divisible by the next prime? Goto step 2


It takes iterations equal to amount of the number's prime factors + the number of primes less than the number that are not prime factors.

—Caerulea
I like it - if it's prime you'll get there eventually, if not you'll find factors well before getting there. That said this could use some modifications - whenever you find p checking p^k for k = 2, 3, 4, 5, .....