Inspired by this Numberphile video
Josephus is part of a group of N soldiers, standing in a circle and about to be captured. To avoid either capture or suicide, his group decides that one soldier (in position 1) will kill the soldier to his left, and the next soldier alive will kill the soldier to his left, and so on, until only one soldier is left. Josephus actually thinks capture is better than being killed, but he doesn't want his fellow soldiers to know it, so he would like to be the last soldier alive before surrendering. What position X should he stand in, in a group of N soldiers, such that he is the last remaining soldier?
ruby josephus.rb