Find all numbers between [i,j] which have lowest common divisor 'D'

55 views Asked by At

We need to find all numbers between [i,j] (inclusive) which have 'D' as it's lowest common divisor(LCD).

Constraints : 1<=i<=j<=2*10^9; 1<=D<=2*10^9;

If the constraints hadn't been that much large, it can be trivially solved using sieve of Eratosthenes.

Any solution to this problem is appreciated.

0

There are 0 answers