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$.