September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
14
Task/Josephus-problem/BASIC/josephus-problem-3.basic
Normal file
14
Task/Josephus-problem/BASIC/josephus-problem-3.basic
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
100 PROGRAM "Josephus.bas"
|
||||
110 INPUT PROMPT "Number of prisoners: ":NP
|
||||
120 INPUT PROMPT "Execution step: ":EX
|
||||
130 INPUT PROMPT "How many survivors: ":SU
|
||||
140 PRINT "Survivors:";
|
||||
150 FOR S=0 TO SU-1
|
||||
160 PRINT JOSEPHUS(NP,EX,S);
|
||||
170 NEXT
|
||||
180 DEF JOSEPHUS(N,K,M)
|
||||
190 FOR I=M+1 TO N
|
||||
200 LET M=MOD((M+K),I)
|
||||
210 NEXT
|
||||
220 LET JOSEPHUS=M
|
||||
230 END DEF
|
||||
Loading…
Add table
Add a link
Reference in a new issue