42isTheAnswer42 / JosephusProblemSolvingAlgorithm

Algorithm to solve the Josephus Problem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JosephusProblemSolvingAlgorithm

Algorithm to solve the Josephus Problem

In computer science and mathematics, the Josephus problem (or Josephus permutation) is a theoretical problem related to a certain counting-out game.

People are standing in a circle waiting to be executed. Counting begins at a specified point in the circle and proceeds around the circle in a specified direction. After a specified number of people are skipped, the next person is executed. The procedure is repeated with the remaining people, starting with the next person, going in the same direction and skipping the same number of people, until only one person remains, and is freed.

The problem — given the number of people, starting point, direction, and number to be skipped — is to choose the position in the initial circle to avoid execution.

Working on HTML you are able to give a number of soldiers as parameters and to calculate the last suviving one. Functions to calculate are in javascript.

About

Algorithm to solve the Josephus Problem


Languages

Language:HTML 100.0%