September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
12
Task/Josephus-problem/ZX-Spectrum-Basic/josephus-problem.zx
Normal file
12
Task/Josephus-problem/ZX-Spectrum-Basic/josephus-problem.zx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
10 LET n=41: LET k=3: LET m=0
|
||||
20 GO SUB 100
|
||||
30 PRINT "n= ";n;TAB (7);"k= ";k;TAB (13);"final survivor= ";lm
|
||||
40 STOP
|
||||
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=FN m(lm+k,a)
|
||||
150 NEXT a
|
||||
160 RETURN
|
||||
200 DEF FN m(x,y)=x-INT (x/y)*y: REM MOD function
|
||||
Loading…
Add table
Add a link
Reference in a new issue