Skip to content

wtachau/josephus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Josephus Problem

Inspired by this Numberphile video

Josephus is part of a group of N soldiers, standing in a circle and about to be captured. To avoid either capture or suicide, his group decides that one soldier (in position 1) will kill the soldier to his left, and the next soldier alive will kill the soldier to his left, and so on, until only one soldier is left. Josephus actually thinks capture is better than being killed, but he doesn't want his fellow soldiers to know it, so he would like to be the last soldier alive before surrendering. What position X should he stand in, in a group of N soldiers, such that he is the last remaining soldier?

To run:

ruby josephus.rb

About

The Josephus Problem

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages