Skip to content

iminfinity/josephus-problem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Josephus Problem

According to legend, the first-century Jewish historian Flavius Josephus was about to be captured along with a band of 40 compatriots by Roman soldiers during the Jewish-Roman War. The Jewish soldiers decided that they preferred suicide to being captured and devised a plan for their demise. They were to form a circle and kill every third soldier until they were all dead. Josephus and one other decided they wanted no part of this and quickly calculated where they needed to place themselves so they would be the last survivors. Where do Josephus and his friend sit in order to survive

Used circular Linked List to solve the problem

Output

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

Start Mayhem

Killed 3
Killed 6
Killed 9
Killed 12
Killed 15
Killed 18
Killed 21
Killed 24
Killed 27
Killed 30
Killed 33
Killed 36
Killed 39
Killed 2
Killed 7
Killed 11
Killed 16
Killed 20
Killed 25
Killed 29
Killed 34
Killed 38
Killed 4
Killed 10
Killed 17
Killed 23
Killed 31
Killed 37
Killed 5
Killed 14
Killed 26
Killed 35
Killed 8
Killed 22
Killed 40
Killed 19
Killed 1
Killed 32

 Josephus and his friend should sit at no:
13
28

About

Josephus Problems

Resources

License

Stars

Watchers

Forks

Contributors