How can I find the smallest positive integer $N$, such that the continued fraction of $\sqrt{N}-\lfloor\sqrt{N}\rfloor$ begins with a given finite sequence containing a zero followed by positive integers ?
For example, the sequence $[0,1,2,3,4]$ is given. We have to find the smallest number $N$, such that $\sqrt{N}-\lfloor\sqrt{N}\rfloor$ begins with $[0,1,2,3,4]$.
The number $\sqrt{388}-\lfloor\sqrt{388}\rfloor$ has continued fraction $[0,1,2,3,4,12,1,\cdots]$ , so $N=388$ is a possible number (In this case, it is the smallest possible number).
The existence of a number $N$ follows from the fact that the sequence $\sqrt{2}\cdot n$ , when $n$ runs over the positive integers which are not a square, is equidistributed modulo $1$, so every rational number in the range $[0,1]$ can be approximated arbitary close, hence the continued fraction will begin with a given sequence.
But I have no idea how to find a possible number (and even better, the smallest possible number) efficiently.
Any ideas ?