Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was reading this Mathworld page on the Josephus problem: from what I understood, once we get the place in execution sequence we can apply inverse permutation (which seems simple) to get the order of execution. But I could not make out how to compute the place in execution sequence, given n, k i.e, for n = 4, k = 2, how to arrive at {4, 1, 3, 2}

I am mostly interested in implementing the solution (I've done the usual circular-list based etc), but if there are better ways, I want to try/understand.

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.