Fool's programing doubt

Guys how you figured out that this problem is a special case of Josephus Problem.