I will write a recursive solution for this famous problem known as "Josephus Problem" . Problem is : There are n people standing in a circle . In each step, a certain number of people are skipped and the next person is executed (killed) . This process continues in the same direction till only 1 person is left who will be the winner . Given the total number of persons n and a number k which indicates that k-1 persons are skipped and kth person is killed in circle.
I will write a recursive solution for this famous problem known as "Josephus Problem" . Problem is : There are n people standing in a circle . In each step, a certain number of people are skipped and the next person is executed (killed) . This process continues in the same direction till only 1 person is left who will be the winner . Given the total number of persons n and a number k which indicates that k-1 persons are skipped and kth person is killed in circle.