This is a variant of the Josephus problem. There are players in a line. Beginning with the first player, move from left to right, removing every player. Alternately, do the same in the other direction. For either process, change the direction at the end of the line. Denote the position of the sole survivor by .
You can see how players are removed with the "demo" button. With the "graph" button you can see the graphs of for and . You can also see the combination of all the graphs for .
The first process of elimination starts counting up from the first player and eliminates the player, the , and so on. The second process counts down from the player and eliminates the player, the , and so on. The first process comes first and the second process second at every stage. The direction changes at either end of the line.
For research on the variants of the Josephus problem, please see the following two papers written by the authors:
R. Miyadera, S. Hashiba, and D. Minematsu, "How High School Students Can Discover Original Ideas of Mathematics Using Mathematica," Mathematica in Education and Research, 11(3), 2006.
H. Matsui, T. Yamauchi, S. Tatsumi, T. Inoue, M. Naito, and R. Miyadera, "Interesting Variants of the Josephus Problem," Kokyuroku (to be published).