Josephus Problem: 100 Soldiers in a Circle Riddle

A popular riddle which you should attempt if you have never came across it.


100 Soldiers are standing in a circle in an order 1 to 100.

No.1 has a sword.

He kills next person (i.e. no. 2) and gives sword to next to next (i.e no.3).

All the soldiers do the same until only 1 survives.

Which number will survive at the end?

So were you able to solve the riddle? Leave your answers in the comment section below.

You can check if your answer is correct by clicking on show answer below. If you get the right answer, please do share the riddle with your friends and family on WhatsApp, Facebook and other social networking sites.

5 thoughts on “Josephus Problem: 100 Soldiers in a Circle Riddle”

  1. import java.io.*;
    import java.util.*;

    public class Solution
    {
    public static void main(String[] args)
    {
    int a,b;
    Scanner sc=new Scanner(System.in);
    a=sc.nextInt();
    b=a;
    int[] arr= new int[40];
    int index=0;
    int[] ar= new int[40];
    int[] arrr= new int[40];
    while(b > 0)
    {
    arr[index++] = b%2;
    b = b/2;
    }
    for(int k=0;k<index;k++)
    {
    ar[k]=arr[index-k-1];
    }
    for(int l=0;l<index-1;l++)
    {
    arrr[l]=ar[l+1];
    }
    arrr[index-1]=ar[0];
    int total=0;
    for(int g = 0; g < index; g++)
    {
    total += Math.pow(2,g) * arrr[index – g – 1];
    }
    System.out.println(total);

    }
    }

    Reply
  2. I got the Josephus problem…but 73 is the correct answer because they wanted to suicide but if we see the riddle here…9, 41, and 73 will be in the last round but if they are forced to do this…then 9 will kill 41 but won’t give the sword to 73..just to kill himself…i mean that way 9 could be the survivor. I mean i got the mathematics but actually didnt get the logic…plz someone explain..

    Reply

Leave a Comment