$N$-th number divisible by a perfect square

409 Views Asked by At

What is the fastest algorithm to determine the $n$-th number divisible by a perfect square? For example,

$n=1$, answer=$4$;

$n=2$, answer=$8$;

$n=3$, answer=$9$;

$n=4$, answer=$12$

1

There are 1 best solutions below

2
On

Sort in ascending order the elements of the set $$\bigcup_{k=2}^{\sqrt n}\left\{k^2l~\bigm|~1\le l\le\left\lfloor\frac n{k^2}\right\rfloor+1\right\}$$ and take the $n^{th}$ element.

But this might not be the most efficient algorithm.