


In the Josephus problem:
1. (n) is the number of people in the circle.
2. (k) is the step size (how many people are skipped before someone is removed).
3. (J(n, k)) represents the position of the winner (last remaining person) in a circle of size (n), counting from 1.
The formula relates the winner's position in a circle of (n) people to the winner's position in a smaller circle of (n-1) people. Here's the step-by-step breakdown:


💡 Each iteration is effectively adding one person back into the "circle" and recalculating the position of the survivor as if the circle were growing.💡
If the below solution is not intuitively comprehensive, try plugging in simple numbers for n and k, perhaps n=4, k=2.
| Name | 0-Based Index (i) | 1-Based Index (i+1) |
|---|---|---|
| Stella | 0 | 1 |
| Amy | 1 | 2 |
| Baily | 2 | 3 |
| Bob | 3 | 4 |
class Solution {
public int findTheWinner(int n, int k) {
int i=0;
for(int j=2;j<=n;j++){
i = (i+k)%j;
}
return i+1;
}
}
jrepresents the number of people that are still playing the game. The game can only be played if there is more than one player because the last player that remains is the winner. So, our reverse calculation for the winner also starts with 2 not 1.
The iterative approach runs in (O(n)), as it computes (J(n, k)) by looping through all circle sizes from 2 to (n).
Looking to find the winner of the circular game? Look no further than the ultimate platform for exciting strategy-based challenges. This addictive game pits players in a thrilling loop where only the smartest survive. Track moves, outwit opponents, and discover who will emerge victorious. At ufamax24.fun the fun never stops, and each round brings a new chance to win. Join today and test your skills in the ultimate circular showdown.
Finding the winner of the circular game is a fun brain teaser—it’s all about patterns and smart elimination. If you're into games like that, you should check out https://familybelle.com/ too. It’s packed with exciting slot games, easy to join, and super entertaining—great for both fun and a chance to win big!
Finding the winner of a circular game can be tricky but fun—it’s all about smart moves and timing. If you enjoy puzzles or strategic games, you’ll love exploring more at https://servicepompaairjogja.net/. They offer cool insights and entertainment options beyond just gameplay. Definitely worth checking out if you're into fun challenges and online excitement!
First time hearing about this game. I read the conditions and didn’t get it. What’s the point of it? A lot of people ask me the same thing when they find out I play at Boomerang Casino https://canadaboomerang.com/ . The point of gambling is at least the chance to win and make some money. And while that’s not my main reason for playing, it’s always a nice bonus when luck’s on your side.