TITLE: What is the position of the surviving mouse?
QUESTION [10 upvotes]: I have this question that I think it may be very interesting to all maths' lovers.
A cat caught $n$ (integer) mice and put them in line, numbered them from 1 to $n$, from left to right.
He starts eating every other mouse, starting with the mouse at the 1st position, i.e. 1, 3, 5 ... (all mice at the odd positions will be gone).
He then starts a new iteration, no matter if there is a surviving mouse at the end of the line, by going back to the left and eats every other mouse again, starting always with the first surviving mouse from the previous iteration.
Until there is one mouse left.
What is the position of the surviving mouse in the original sequence from 1 to n?

REPLY [17 votes]: The other answers are correct, but let me offer an alternative way to see it.
Suppose you had 7 mouses, for example.
Number them in binary and go through the cat's iterations:

001 -> 001
  010 -> 010 -> 010
  011 -> 011
  100 -> 100 -> 100
  101 -> 101
  110 -> 110 -> 110
  111 -> 111

In the first round the cat eats all mice ending in 1, so that only the ones ending in 0 are left.
On the second round the cat eats all mice ending in 10, so that only the ones ending in 00 are left.
And so on.
(Alternatively, you can drop one trailing zero from all mice after the first round and iterate with always eating mice ending in 1.)
That is, if a mouse has $k$ trailing zeroes, it will survive exactly $k$ rounds.
The last survivor is the one with the largest amount of trailing zeroes.
The number of trailing zeroes in the set $\{1,\dots,n\}$ is always maximized by a power of two and the maximizer is unique.
(Please ask if you want a proof for this statement. It might work as a separate question, too.)
The largest power of two that does not exceed $n$ is indeed $a_n = 2^{\lfloor \log_2 n \rfloor}$ as others have pointed out.