I think prime numbers would be best if you are looking at factors. Maybe something like:
- Is the number divisible by prime p?
- If Yes: store p and ask about two again, If no:
- Is the next prime large than the number? If so: break. (There is probably a smaller end condition that could be used).
- 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