Definition:Josephus Problem

Problem
The legend goes that Flavius Josephus was holed up in a cave with a bunch of comrades, hiding from a band of Roman soldiers. Death was preferable to capture, so they determined a procedure whereby they would all commit ritual suicide.

They all stood in a circle, and counted round. Every third person was killed, and the gap was closed. However, Josephus (and possibly a co-conspirator) figured out where to stand in the circle so as to be last to be picked. He (or they) gave themselves up to the Romans.

General Statement
For a given a number of people, and a given step size, to determine the position of the last person to be counted.

The exercise is familiar to schoolchildren the world over.