Skip to content

Instantly share code, notes, and snippets.

@birkir
Created December 9, 2014 10:51
Show Gist options
  • Save birkir/fbca1b273e8e4c219860 to your computer and use it in GitHub Desktop.
Save birkir/fbca1b273e8e4c219860 to your computer and use it in GitHub Desktop.
Jóladagatal 9/24 - Skrítnar tölur
81
2.025
3.025
9.801
494.209
998.001
24.502.500
25.502.500
52.881.984
60.481.729
99.980.001
var i = 0;
while (true) {
// only numbers in length of mod 2
if ((i+'').length % 2 !== 0) i *= 10;
// get first and last part of number
var a = (i+''),
b = parseInt(a.substr(0, a.length / 2), 0),
c = parseInt(a.substr(a.length / 2), 0);
// print number if the parts sum with power of two is equal to number
if (i === Math.pow(b + c, 2)) console.log(i);
// iterate
i++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment