Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Josephus-problem/GW-BASIC/josephus-problem.basic
Normal file
13
Task/Josephus-problem/GW-BASIC/josephus-problem.basic
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
10 LET N = 41
|
||||
20 LET K = 3
|
||||
30 LET M = 0
|
||||
40 GOSUB 100
|
||||
50 PRINT "n ="; N, "k ="; K, "final survivor ="; LM
|
||||
60 END
|
||||
100 REM Josephus
|
||||
110 REM Return m-th on the reversed kill list; m=0 is final survivor.
|
||||
120 LET LM = M : REM Local copy of m
|
||||
130 FOR A = M+1 TO N
|
||||
140 LET LM = (LM+K) MOD A: REM MOD function
|
||||
150 NEXT A
|
||||
160 RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue