Skip to content

Instantly share code, notes, and snippets.

@wookimiii
Created April 15, 2014 19:24
Show Gist options
  • Save wookimiii/10762415 to your computer and use it in GitHub Desktop.
Save wookimiii/10762415 to your computer and use it in GitHub Desktop.
Torn number
var a, b, s;
for (var i=1000; i < 9999; i++) {
s = Math.sqrt(i);
if (s%1 == 0) {
a = Number(i.toString().substring(0, 2));
b = Number(i.toString().substring(2, 4));
if ( a + b == s) {
console.log(a, b);
}
}
}
/** output
20 25
30 25
98 1
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment