Josephus problem: Difference between revisions

Content added Content deleted
m (ANSI Standard BASIC and BBC BASIC moved to the BASIC section.)
(→‎{{header|ANSI Standard BASIC}}: Changed to {{header|ANSI BASIC}}; {{works with|Decimal BASIC}}; output.)
Line 1,026: Line 1,026:
<pre>Survivor is number 30</pre>
<pre>Survivor is number 30</pre>


==={{header|ANSI Standard BASIC}}===
==={{header|ANSI BASIC}}===
{{trans|ALGOL 68}}
{{trans|ALGOL 68}}
{{works with|Decimal BASIC}}
<syntaxhighlight lang="ansi standard basic">100 FUNCTION josephus (n, k, m)
<syntaxhighlight lang="basic">100 FUNCTION josephus (n, k, m)
110 ! Return m-th on the reversed kill list; m=0 is final survivor.
110 ! Return m-th on the reversed kill list; m=0 is final survivor.
120 LET lm = m ! Local copy OF m
120 LET lm = m ! Local copy OF m
Line 1,041: Line 1,042:
210 END
210 END
</syntaxhighlight>
</syntaxhighlight>
{{out}}
<pre>
n = 41 k = 3 final survivor = 30
</pre>


==={{header|Applesoft BASIC}}===
==={{header|Applesoft BASIC}}===