In the following we only consider positive integers.


Given a large $n$ and $N\in(n^2, \ n^2+n)$ fixed, consider 


$\min \{p/q \ : \ p>q, \ n^2<p\cdot q<N \}$.


For example, $n=20$, as $N$ increases, the closest cases happen like this:


$403=31\times 13$


$405=27\times 15$


$408=24\times 17$


$414=23\times 18$


$418=22\times 19$


Is there any estimate as a function of $n$ and $N$ when $n$ is large? 


What if $n(n+1)<N<n(n+2)?$


Thanks a lot.



Find $N=p\cdot q \in \big(n^2, \ n(n+1)\big)$ with the "closest" factors $p, q$ in the sense of $p/q$
Your examples, plus one more, are 


$403=(20+11)(20-7)$


$405=(20+7)(20-5)$


$408=(20+4)(20-3)$


$414=(20+3)(20-2)$


$418=(20+2)(20-1)$


$420=(20+1)(20-0)$


If you allowed me to start with 


$400=(20+5)(20-4)$ that would be the champion until $408=(20^2+2\lfloor \sqrt{20} \rfloor).$ This is a special situation which occurs when $n=k(k+1)$ so $n^2=(n+k+1)(n-k).$


One sees (and can prove) that at some point the record breakers are $(n+j+1)(n-j)$ for $j$ descending to $1$ (or $0$ if you continue to $n^2+n.$) The largest $j$ which works is $ \lfloor-1/2+1/2\,\sqrt {1+4\,n}\rfloor.$ There is a slight exception in the case $n=k(k+1)$ (as with $n=20$.) Then $-1/2+1/2\,\sqrt {1+4\,n}=k$ but you must, unless the rules are changed, start with $j=k-1.$


Given $n,$ let $m$ be the smallest integer with $n\lt m^2+m.$ This is the largest $j$ mentioned and, starting with $j=m$ and $N=(n+m+1)(n-m)$ we will have the record breakers being $(n+j+1)(n-j).$ In the case $n=21$ this starts immediately at $21^2+1=442=(21+5)(21-4).$ Actually, as mentioned, the case you did of $n=20$ is the worst kind for $N-n^2,$ unless you change the rules to allow it to be the best. This is the case that that $n=k(k+1)$ when the rule $n \lt m(m+1)$ forces $m=k-1$ and $(n+m+1)(n-m)=(n+k)(n-(k-1))=n^2+2k.$


I leave the analysis , if desired, of what happens immediately after $n^2$ to others.


