[ stack ] is survivors ( --> s ) [ stack ] is prisoners ( --> s ) [ stack ] is executioner-actions ( --> s ) [ [] swap times [ i^ join ] prisoners put ] is make-prisoners ( n --> ) [ prisoners take behead join prisoners put ] is walk ( --> ) [ prisoners take behead drop prisoners put ] is kill ( --> ) [ [] swap 1 - times [ ' walk nested join ] ' kill nested join executioner-actions put ] is make-executioner ( n --> ) [ executioner-actions take behead dup do nested join executioner-actions put ] is execute-kth ( --> ) [ survivors put make-executioner make-prisoners [ execute-kth prisoners share size survivors share = until ] survivors release executioner-actions release prisoners take ] is josephus ( n n n --> n )