SlideShare a Scribd company logo
1 of 41
The
Josephus
Problem
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 Josephus Problem
The problem is named after Flavius Josephus, a Jewish
historian living in the 1st century. According to Josephus'
account of the siege of Yodfat, he and his 40 soldiers were
trapped in a cave by Roman soldiers. They chose suicide
over capture, and settled on a serial method of
committing suicide by drawing lots. Josephus states that
by luck or possibly by the hand of God, he and another
man remained until the end and surrendered to the
Romans rather than killing themselves. This is the story
given in Book 3, Chapter 8, part 7 of Josephus' The Jewish
War
The Josephus Problem
Variation of the problem
we start with n people numbered 1 to n
around a circle
The Josephus Problem
1
6
7
8
9
10 2
3
4
5
The Josephus Problem
1
6
7
8
9
10 2
3
4
5
The Josephus Problem
1
6
7
8
9
10 2
3
4
5
The Josephus Problem
1
6
7
8
9
10 2
3
4
5
The Josephus Problem
1
6
7
8
9
10 2
3
4
5
The Josephus Problem
1
6
7
8
9
10 2
3
4
5
The Josephus Problem
1
6
7
8
9
10 2
3
4
5
The Josephus Problem
1
6
7
8
9
10 2
3
4
5
The Josephus Problem
1
6
7
8
9
10 2
3
4
5
The Josephus Problem
1
6
7
8
9
10 2
3
4
5
The Josephus Problem
1 1
j jn
The Josephus Problem
2 1
j jn
1
1jn
j
The Josephus Problem
3 3
j jn
1
1
2
1
j
jn
The Josephus Problem
4 1
j jn
1
1
2
1
3
3
j
jn
The Josephus Problem
5 3
j jn
1
1
2
1
3
3
4
1
j
jn
The Josephus Problem
6 5
j jn
1
1
2
1
3
3
4
1
5
3
j
jn
The Josephus Problem
7 7
j jn
1
1
2
1
3
3
4
1
5
3
6
5
j
jn
The Josephus Problem
8 1
j jn
1
1
2
1
3
3
4
1
5
3
6
5
7
7
j
jn
The Josephus Problem
9 3
j jn
1
1
2
1
3
3
4
1
5
3
6
5
7
7
8
1
j
jn
The Josephus Problem
10 5
j jn
1
1
2
1
3
3
4
1
5
3
6
5
7
7
8
1
9
3
j
jn
The Josephus Problem
11 7
j jn
1
1
2
1
3
3
4
1
5
3
6
5
7
7
8
1
9
3
10
5
j
jn
The Josephus Problem
12 9
j jn
1
1
2
1
3
3
4
1
5
3
6
5
7
7
8
1
9
3
10
5
11
7
j
jn
The Josephus Problem
13 11
j jn
1
1
2
1
3
3
4
1
5
3
6
5
7
7
8
1
9
3
10
5
11
7
12
9
j
jn
The Josephus Problem
14 13
j jn
1
1
2
1
3
3
4
1
5
3
6
5
7
7
8
1
9
3
10
5
11
7
12
9
13
11
j
jn
The Josephus Problem
15 15
j jn
1
1
2
1
3
3
4
1
5
3
6
5
7
7
8
1
9
3
10
5
11
7
12
9
13
11
14
13
j
jn
The Josephus Problem
16 1
j jn
1
1
2
1
3
3
4
1
5
3
6
5
7
7
8
1
9
3
10
5
11
7
12
9
13
11
14
13
15
15
16
1
j
jn
The Josephus Problem
1
1
2
1
3
3
4
1
5
3
6
5
7
7
8
1
9
3
10
5
11
7
12
9
13
11
14
13
15
15
16
1
j
jn
The Josephus Problem
1
1
2
1
3
3
4
1
5
3
6
5
7
7
8
1
9
3
10
5
11
7
12
9
13
11
14
13
15
15
16
1
j
jn
The Josephus Problem
1
1
2
1
3
3
4
1
5
3
6
5
7
7
8
1
9
3
10
5
11
7
12
9
13
11
14
13
15
15
16
1
j
jn
The Josephus Problem
1
1
2
1
3
3
4
1
5
3
6
5
7
7
8
1
9
3
10
5
11
7
12
9
13
11
14
13
15
15
16
1
j
jn
2
n
The Josephus Problem
1
1
2
1
3
3
4
1
5
3
6
5
7
7
8
1
9
3
10
5
11
7
12
9
13
11
14
13
15
15
16
1
j
jn
j
jn
32
1
64
1
128
1
256
1
512
1
1024
1
2048
1
4096
1
8192
1
The Josephus Problem
Bit
D-B
1
1
2
0
4
0
8
1
16
0
32
1
64
41
N = 41
B-D 1 1 0 0 1 0 19
32+8+1 = 41 16+2+1 = 19
=
=
The Josephus Problem
41 19
j jn
The Josephus Problem
Recurrent equation
J (1) = 1;
J (2n) = 2J (n) – 1; for n≥1
J (2n+1) = 2J (n) + 1; for n≥1
EVEN
ODD
The Josephus Problem
Recurrent equation
J(41) = 2 J(20)+1 = 2 x 9 + 1 = 19
J(20) = 2 J(10)-1 = 2 x 5 - 1 = 9
J(10) = 2 J(5)-1 = 2 x 3 - 1 = 5
J(5) = 2 J(2)+1 = 2 x 1 + 1 = 3
J(2) = 2 J(1)-1 = 2 x 1 - 1 = 1
J(1) = 1
The Josephus Problem
Close Formula
41 = 2 +9 = 2x9+15
= 19
The Josephus Problem
Thank
You

More Related Content

What's hot

Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptkarthikaparthasarath
 
Backtracking & branch and bound
Backtracking & branch and boundBacktracking & branch and bound
Backtracking & branch and boundVipul Chauhan
 
Artificial intelligence- Logic Agents
Artificial intelligence- Logic AgentsArtificial intelligence- Logic Agents
Artificial intelligence- Logic AgentsNuruzzaman Milon
 
Tower Of Hanoi -A MatheMatical PuZzle
Tower Of Hanoi -A MatheMatical PuZzleTower Of Hanoi -A MatheMatical PuZzle
Tower Of Hanoi -A MatheMatical PuZzlepurvanahar
 
Karnaugh map
Karnaugh mapKarnaugh map
Karnaugh mapchandkec
 
boolean algrebra and logic gates in short
boolean algrebra and logic gates in shortboolean algrebra and logic gates in short
boolean algrebra and logic gates in shortRojin Khadka
 
Interpolation with Finite differences
Interpolation with Finite differencesInterpolation with Finite differences
Interpolation with Finite differencesDr. Nirav Vyas
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic ProgrammingSahil Kumar
 
Resolution method in AI.pptx
Resolution method in AI.pptxResolution method in AI.pptx
Resolution method in AI.pptxAbdullah251975
 
Mathematical foundations of computer science
Mathematical foundations of computer scienceMathematical foundations of computer science
Mathematical foundations of computer scienceBindhuBhargaviTalasi
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen ProblemSukrit Gupta
 

What's hot (20)

First order logic
First order logicFirst order logic
First order logic
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.ppt
 
Backtracking & branch and bound
Backtracking & branch and boundBacktracking & branch and bound
Backtracking & branch and bound
 
Introduction to Prolog
Introduction to PrologIntroduction to Prolog
Introduction to Prolog
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 
Artificial intelligence- Logic Agents
Artificial intelligence- Logic AgentsArtificial intelligence- Logic Agents
Artificial intelligence- Logic Agents
 
Tower Of Hanoi -A MatheMatical PuZzle
Tower Of Hanoi -A MatheMatical PuZzleTower Of Hanoi -A MatheMatical PuZzle
Tower Of Hanoi -A MatheMatical PuZzle
 
METHOD OF JACOBI
METHOD OF JACOBIMETHOD OF JACOBI
METHOD OF JACOBI
 
Karnaugh map
Karnaugh mapKarnaugh map
Karnaugh map
 
boolean algrebra and logic gates in short
boolean algrebra and logic gates in shortboolean algrebra and logic gates in short
boolean algrebra and logic gates in short
 
Interpolation with Finite differences
Interpolation with Finite differencesInterpolation with Finite differences
Interpolation with Finite differences
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 
Big o notation
Big o notationBig o notation
Big o notation
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Resolution method in AI.pptx
Resolution method in AI.pptxResolution method in AI.pptx
Resolution method in AI.pptx
 
Predicate logic
 Predicate logic Predicate logic
Predicate logic
 
Pigeon hole principle
Pigeon hole principlePigeon hole principle
Pigeon hole principle
 
Mathematical foundations of computer science
Mathematical foundations of computer scienceMathematical foundations of computer science
Mathematical foundations of computer science
 
Loop invarient
Loop invarientLoop invarient
Loop invarient
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen Problem
 

Recently uploaded

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 

Recently uploaded (20)

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 

Josephus problem