You are viewing a single comment's thread. Return to all comments →
Javascript Solution
function counterGame(n) { function checkBase(number) { const base = Math.log(number) / Math.log(2); if (Number.isInteger(base)) { return number / 2; } else { const closestBase = Math.floor(base); return number - 2 ** closestBase; } } let counter = 0; while (n > 1) { n = checkBase(n); counter++; } if (counter % 2 === 1) { return "Louise"; } else { return "Richard"; } }
Seems like cookies are disabled on this browser, please enable them to open this website
Counter game
You are viewing a single comment's thread. Return to all comments →
Javascript Solution