josephus - Killing in Circles!

I found this problem: https://www.hackerearth.com/problem/algorithm/a-dynamic-josephus-problem-1/

i only know the recursive way to find the survivor.
can someone explain me how to solve this problem!

1 Like

See this http://www.geeksforgeeks.org/josephus-problem-set-1-a-on-solution/ this might help you.

See the following links:

The Josephus Problem - Numberphile https://www.youtube.com/watch?v=uCsD3ZGzMgE

Solving the Generic Josephus Problem, Part 1 https://www.youtube.com/watch?v=7Ezs8UtNK9s

Solving the Generic Josephus Problem, Part 2 https://www.youtube.com/watch?v=VH9Yvy9pb84

CodeChef Practice problem(Hard) JOSEPHUS

Simple Solution to the above problem https://www.codechef.com/viewsolution/22076928

Following the above link will greatly help with the concept of the Josephus problem.
It helped me quite a lot.

Good luck!! Cheers!!