RosettaCodeData/Task/Josephus-problem/PowerShell/josephus-problem-2.ps1
2026-04-30 12:34:36 -04:00

12 lines
360 B
PowerShell

# Get the prisoner order for a circle of 41 prisoners, selecting every third
$Prisoners = Get-JosephusPrisoners -N 41 -K 3
# Display the prisoner order
$Prisoners -join " "
# Display the last remaining prisoner
"Last prisoner remmaining: " + $Prisoners[-1]
# Display the last three remaining prisoners
$S = 3
"Last $S remaining: " + $Prisoners[-$S..-1]