Skip to content

Instantly share code, notes, and snippets.

@mt-xing
Created July 3, 2020 21:40
Show Gist options
  • Save mt-xing/a7499eb784fa472bb6e125214f31da90 to your computer and use it in GitHub Desktop.
Save mt-xing/a7499eb784fa472bb6e125214f31da90 to your computer and use it in GitHub Desktop.
538's Riddler
for(let i = 52; true; i += 2) {
if(isGood(i)) {
console.log(i);
break;
}
}
function isGood(i) {
let sq = i / 2;
if(!Number.isInteger(Math.sqrt(sq))){
return false;
}
i *= 2;
i /= 5;
sq = Math.floor(Math.sqrt(i));
return sq * (sq + 1) == i;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment