Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

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

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages