Speeded up algorithm for finding divisors.