Created
July 3, 2020 21:40
-
-
Save mt-xing/a7499eb784fa472bb6e125214f31da90 to your computer and use it in GitHub Desktop.
538's Riddler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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