sahasatvik / SwordPuzzle

A program to find the solution to the Josephus Problem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SwordPuzzle

A program to find the solution of an interesting puzzle ...

The Puzzle

In this puzzle, we have N number of people standing in a circle. They are numbered (1 - N). Initially, the first person carries a sword. The 'sword carrier' kills the next person, then passes it to the next person standing. This continues until only 1 person is still alive.

Who is the last person standing?

How to use this program

Compile the Puzzle.java file to get a Puzzle.class file :

    javac Puzzle.java

(the .class file is available in the repository) ... and run it as follows :

    java Puzzle [number of people - 100 by default] [number of people to be left alive - 1 by default]

About

A program to find the solution to the Josephus Problem

License:MIT License


Languages

Language:Java 100.0%