func josephus(n, k) {
var prisoners = @^n
while (prisoners.len > 1) {
prisoners.rotate!(k - 1).shift
}
return prisoners[0]
}
func josephus(n, k) {
n == 1 ? 0 : ((__FUNC__(n-1, k) + k) % n)
}
var survivor = josephus(41, 3)
say "Prisoner #{survivor} survived."