You are viewing a single comment's thread. Return to all comments →
JavaScript Solution (using Math Library):
function counterGame(n) { let isLouiseTurn = true let numberValue= n while(numberValue!==1) { isLouiseTurn = !isLouiseTurn const logValue = Math.log2(numberValue) if(logValue % 1 === 0) numberValue /=2 else numberValue -= Math.pow(2,Math.floor(logValue)) } return isLouiseTurn ? 'Richard' : 'Louise' }
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 (using Math Library):