Simple problem of divisibility.

29 Views Asked by At

Given a number N, N <= 10 ^ 10 and given a integer d, also we are given an integer R we have to find integer L such that

for every integer i from L to R the integer division (N / i) = d

it is gaurented that N / R (integer division) is d

1

There are 1 best solutions below

0
On BEST ANSWER

Let be $k$ the greatest integer such that $N/k\geq d+1$. Since $N/R=d$, there exists some integer $j$ such that $N/j=d$, so $N/(k+1)=d$ (note that if the divisor increases, the quotient decreases). So you can simply take $L=k+1$.

Obviously, I have used the symbol $/$ to denote integer division.

If you need an explicit formula for $k$, simply write: $$N/k\geq d+1\Leftrightarrow \frac{N}{k}\geq d+1 \Leftrightarrow \frac N{d+1}\geq k$$ so $k=\left\lfloor\frac N{d+1}\right\rfloor$ and $L=\left\lfloor\frac N{d+1}\right\rfloor+1$.

Remark: it is possible that $L=R$.