Divisors of a number in a given range

176 Views Asked by At

I'm working on a problem and wondered if there was a clever way to do it. The general form of the problem is like this: given $\ell_1,\ell_2,$ and $N$, find all divisors $d$ of $N$ with $\ell_1\le d\le\ell_2.$ I have the full factorization of $N$, which is much larger than $\ell_2.$ Also the number of divisors of $N$ is much larger than $\ell_2$: in my case $\Omega(N)=932=\omega(N).$

Right now I'm solving it by brute force: loop from $\ell_1$ to $\ell_2$ and test if the number divides $N.$ But surely there's a better way!