Josephus problem: Difference between revisions
Content added Content deleted
(Dialects of BASIC moved to the BASIC section.) |
(→{{header|Palo Alto Tiny BASIC}}: Added a solution.) |
||
Line 1,279: | Line 1,279: | ||
==={{header|MSX Basic}}=== |
==={{header|MSX Basic}}=== |
||
The [[#GW-BASIC|GW-BASIC]] solution works without any changes. |
The [[#GW-BASIC|GW-BASIC]] solution works without any changes. |
||
==={{header|Palo Alto Tiny BASIC}}=== |
|||
{{trans|ANSI BASIC}} |
|||
<syntaxhighlight lang="basic"> |
|||
10 REM JOSEPHUS PROBLEM |
|||
20 LET N=41,K=3,M=0 |
|||
30 GOSUB 100 |
|||
40 PRINT #1,"N =",N,", K =",K,", FINAL SURVIVOR =",L |
|||
50 STOP |
|||
90 REM ** JOSEPHUS |
|||
100 LET L=M |
|||
110 FOR A=M+1 TO N |
|||
120 LET L=L+K-((L+K)/A)*A |
|||
130 NEXT A |
|||
140 RETURN |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
N = 41, K = 3, FINAL SURVIVOR = 30 |
|||
</pre> |
|||
==={{header|PureBasic}}=== |
==={{header|PureBasic}}=== |