Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
12
Task/Josephus-problem/ANSI-BASIC/josephus-problem.basic
Normal file
12
Task/Josephus-problem/ANSI-BASIC/josephus-problem.basic
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
100 FUNCTION josephus (n, k, m)
|
||||
110 ! Return m-th on the reversed kill list; m=0 is final survivor.
|
||||
120 LET lm = m ! Local copy OF m
|
||||
130 FOR a = m+1 TO n
|
||||
140 LET lm = MOD(lm+k, a)
|
||||
150 NEXT a
|
||||
160 LET josephus = lm
|
||||
170 END FUNCTION
|
||||
180 LET n = 41
|
||||
190 LET k=3
|
||||
200 PRINT "n =";n, "k =";k,"final survivor =";josephus(n, k, 0)
|
||||
210 END
|
||||
Loading…
Add table
Add a link
Reference in a new issue