Josephus problem: Difference between revisions

Content added Content deleted
Line 1,441: Line 1,441:
CL-USER > (kill 41 3)
CL-USER > (kill 41 3)
30
30

=={{header|Craft Basic}}==
<syntaxhighlight lang="basic">'using 1 to n

define prisoners = 0, step = 0, killcount = 0, survivor = 0
define fn (josephus) as ( survivor + step ) % killcount

do

input "Prisoners", prisoners
input "Step", step

gosub executioner

loop

sub executioner

let killcount = 1

do

let killcount = killcount + 1
let survivor = (josephus)

loop killcount < prisoners

print "survivor = ", survivor

return</syntaxhighlight>


=={{header|Crystal}}==
=={{header|Crystal}}==