Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
23
Task/Josephus-problem/Pascal-P/josephus-problem.pas
Normal file
23
Task/Josephus-problem/Pascal-P/josephus-problem.pas
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
program josephus(output);
|
||||
|
||||
(* Josephus problem *)
|
||||
var
|
||||
n, k, m: integer;
|
||||
|
||||
function josephus(n, k, m: integer): integer;
|
||||
var
|
||||
a, j: integer;
|
||||
begin
|
||||
j := m;
|
||||
for a := m + 1 to n do
|
||||
j := (j + k) mod a;
|
||||
josephus := j;
|
||||
end;
|
||||
|
||||
begin
|
||||
n := 41;
|
||||
k := 3;
|
||||
m := 0;
|
||||
writeln('N = ', n:1, ', K = ', k:1, ', Final survivor = ', josephus(n, k, m):1);
|
||||
(* readln; *)
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue