forked from devAmoghS/Python-Interview-Problems-for-Practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit edb6544
authored
Update josephus_improved.py
The equation to the Josepus problem, W(n) = 2L + 1, has a constraint in which L < 2^a (The biggest power of 2 inside the number of soldiers, in this case the variable p).
This means if n is a power of 2, the winning position will always be 1, so the formula would be wrong.1 parent 0d0c7df commit edb6544
1 file changed
+5
-1
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
15 | - | ||
15 | + | ||
16 | + | ||
17 | + | ||
18 | + | ||
19 | + | ||
16 | 20 |
| |
17 | 21 |
| |
18 | 22 |
| |
|
0 commit comments