Efficient removal of divisors in the k-ary algorithm

Efficient removal of divisors in the k-ary algorithm