• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
August 22, 2024 |47.2K Views

Josephus Problem

  Share  2 Likes
Description
Discussion

The simple approach is to create a list and add all values from 1 to n to it. Create a recursive function that takes a list, start (position at which counting will start), and k ( number of people to be skipped) as an argument. If the size of the list is one i.e. only one person left then return this position. 

Otherwise, start counting the k person in a clockwise direction from starting position and remove the person at the kth position. Now the person at the kth position is removed and now counting will start from this position. This process continues till only one person is left.

Josephus Problem : https://www.geeksforgeeks.org/josephus-problem-set-1-a-on-solution/