Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I was reading this Mathworld page on the Josephus problem: http://mathworld.wolfram.com/JosephusProblem.html 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
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.