You are viewing a single comment's thread. Return to all comments →
function counterGame(n){ const player = ['Louise', 'Richard']; let count = 0; while ( n > 1 ){ let p = 0; while ( 2**p < n){ p++; } if ( 2**p === n ) n/=2; else n -=2**(p-1); count++; } return player[(count+1)%2]; }
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 →