Save the Prisoner!

Problem
A jail has a number of prisoners and a number of treats to pass out to them. Their jailer decides the fairest way to divide the treats is to seat the prisoners around a circular table in sequentially numbered chairs. A chair number will be drawn from a hat. Beginning with the prisoner in that chair, one candy will be handed to each prisoner sequentially around the table until all have been distributed.
The jailer is playing a little joke, though. The last piece of candy looks like all the others, but it tastes awful. Determine the chair number occupied by the prisoner who will receive that candy.
For example, there are 4
prisoners and 6
pieces of candy. The prisoners arrange themselves in seats numbered 1
to 4
. Let’s suppose two is drawn from the hat. Prisoners receive candy at positions 2, 3, 4, 1, 2, 3
. The prisoner to be warned sits in chair number 3
.
Function Description
Complete the saveThePrisoner function in the editor below. It should return an integer representing the chair number of the prisoner to warn.
saveThePrisoner has the following parameter(s):
n
: an integer, the number of prisonersm
: an integer, the number of sweetss
: an integer, the chair number to begin passing out sweets from
My Solution
I’m providing the solution for Python and JS, please leave on the comments if you found a better way.
Si te gusta el contenido, por favor apoya mi trabajo!

Juan Cruz Martinez
¡Hola!
Soy Juan Cruz Martinez, el fundador de LiveCodeStream.dev. Me encanta programar y creo en el poder de la programación no solo para construir un mundo mejor, sino para hacer que TU vida sea mejor.
Fundé LiveCodeStream.dev porque quería ayudarte a aprender a programar, construir una mejor carrera y, en última instancia, crear una vida mejor. Eso me sucedió hace más de una década cuando comencé a programar, y le sucede a decenas de miles de personas a diario. Quiero que TÚ te unas a esa revolución.
No importa cómo lo llames, escribir código, programación, desarrollo de software o cualquier otra cosa, las habilidades involucradas están en una demanda cada vez mayor. Y ya sea que quieras incursionar en el desarrollo de sitios web, diseño de juegos, desarrollo de blockchain o cualquier otra cosa, quiero ayudarte.