How many days are needed to find the robot? There is a row of $n$ opaque boxes numbered from $1$ to $n$.
A robot is programmed with an ordered pair of numbers $(x,y)$, each being integers between $1$ and $n$, inclusive.
$x$ is the box the robot will be in on the first day, and $y$ is the "speed" of the robot: each night the robot adds $y$ to its current box number and moves to that new box. If the sum exceeds $n$, then the robot subtracts $n$ to determine its new box.
You may open one box per day. How many days are needed to guarantee finding the robot? More specifically, is there a formula (explicit or recursive) based on $n$?
I've made only a little progress working by hand.




Number of boxes, $n$
Days to find the robot




$1$
$1$


$2$
$3$


$3$
$4$


$4$
$5$




For $n=3$ my solution is $1,1,3,2$. For $n=4$ my solution is $1,4,3,4,2$. For $n=5$ the best I can do is $9$ days, but I'm not confident about that being optimal.
These came from using a greedy algorithm like approach: I listed out all the possible sequences of the robot's positions and on each day looked for which box I could open that would eliminate most of the remaining sequences.
I tried searching $1,3,4,5,9$ in OEIS and it came back with these so-called Stone Skipping Numbers. I don't fully understand what the comments mean, but it seems to not be analogous to my box problem.
EDIT/UPDATE:
For $n=6$ boxes, I found a solution of $9$ days, which is: $1,2,6,5,4,4,3,4,2$.
I also know that if $n$ is a prime number, then the robot can be found in at most $2n-1$ days by the following process: Open box #$1$ on each of the first $n$ days. This will capture all robots except the ones that are stationary in the other boxes. Then open boxes $2$ through $n$ on days $n+1$ through $2n-1$.
 A: Here's a proof that the optimal answer for $n = p$ prime is $2p - 1$.
If we open box $a_i$ on day $i$, then to find the robot in $t$ days we need
$$\prod_{i = 1}^t (x + iy - a_i) = 0$$
for all $(x, y) \in \mathbb{F}_p^2$. So the polynomial on LHS must be identically zero on $\mathbb{F}_p^2$, which is equivalent to the fact that the polynomial is zero in the ring $\mathbb{F}_p[x, y] / (x^p - x, y^p - y)$.
It is clearly impossible that $t < p$. Now suppose $p \leq t < 2p - 1$. We consider the coefficient of the monomial $x^{t - p + 1} y^{p - 1}$ in the standard basis $\{x^i y^j: (i, j) \in [0, p - 1]^2\}$ of $\mathbb{F}_p[x, y] / (x^p - x, y^p - y)$. By degree counting(the crucial observation is that $t - p + 1 \leq p - 1$, so only monomials with degree $t$ or higher would contribute to the coefficient of this monomial), the coefficient of $x^{t - p + 1} y^{p - 1}$ is equal to its coefficient in
$$\prod_{i = 1}^t (x + iy) = (x^{p - 1} - y^{p - 1})x\prod_{i = 1}^{t - p} (x + iy)$$
which is the nonzero $-1$, contradiction. So we must have $t \geq 2p - 1$.
