Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Josephus-problem/ALGOL-68/josephus-problem.alg
Normal file
12
Task/Josephus-problem/ALGOL-68/josephus-problem.alg
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
BEGIN
|
||||
PROC josephus = (INT n, k, m) INT :
|
||||
CO Return m-th on the reversed kill list; m=0 is final survivor. CO
|
||||
BEGIN
|
||||
INT lm := m; CO Local copy of m CO
|
||||
FOR a FROM m+1 WHILE a <= n DO lm := (lm+k) %* a OD;
|
||||
lm
|
||||
END;
|
||||
INT n = 41, k=3;
|
||||
printf (($"n = ", g(0), ", k = ", g(0), ", final survivor: ", g(0)l$,
|
||||
n, k, josephus (n, k, 0)))
|
||||
END
|
||||
Loading…
Add table
Add a link
Reference in a new issue