ProgrammingHardGATE CS · Campus placements

Six people stand in a circle numbered 1 to 6; starting from 1, every second person is removed until one remains. Which number survives? This is the Josephus problem with n = 6 and k = 2.

  1. A. 1
  2. B. 6
  3. C. 5
  4. D. 3

Correct answer: C. 5

The removal order is 2, 4, 6, 3, 1, leaving 5. The recurrence J(n) = (J(n-1) + 2) mod n confirms the same survivor.

More C Programming questions

Exams that ask this topic