DEV Community

Minh Hieu
Minh Hieu

Posted on

Save the Prisoner Explain Solution | Javascript

function saveThePrisoner(n, m, s) {
  console.log((m-1 + s) % n)
  return (m-1 + s)%n || n;
}

saveThePrisoner(3, 1, 2);

Problem

Top comments (0)