Sunday, March 11, 2018

Removing perfect squares

Apparently this is from topcoder, but I believe there must be a more original source for this.

You start with $n$ cards numbered $1,2, \dots n$ placed in order along a line.

Now you make a pass through the cards and remove any that have a perfect square on them. Then you renumber the cards as $1,2 \dots K$ (making sure to maintain the ordering) and keep doing the process of removal and renumbering till there is only one card left.

What was the original number of that card? Can you give a formula in terms of $n$?