I am dealing with a polynomial of the form $$p(a,b) = a^n - b^n $$ for integer values $a > b$, and some small integer $n$. I am wanting to factor this polynomial for a large range of values (for example, let $a$ range from 2 to 1000000 and for each $a$ let $b$ range from 1 to $a-1$). At the moment I am factoring each value of $p(a,b)$ independently using a quadratic sieve in sage. It seems like this could be done much faster if I used some sort of sieve (similar to the sieve of Eratosthenes) to factor each value of the polynomial, knowing divisibility properties of different values would be intimately related. Ive tried to implement this but I cant seem to figure out how to do it.
Does anyone have any suggestions?