Created
February 13, 2017 07:41
-
-
Save DonMartin76/3c61e30f86af40647923c46c3802fa8b to your computer and use it in GitHub Desktop.
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
'use strict'; | |
let i = 2; | |
let done = false; | |
while (!done) { | |
console.log("Checking " + i); | |
const i3 = i.toString(3); | |
const i4 = i.toString(4); | |
const i5 = i.toString(5); | |
if (hasOnly01(i3) && hasOnly01(i4) && hasOnly01(i5)) { | |
const i2 = i.toString(2); | |
console.log("Yay!"); | |
console.log(i2 + ", " + i3 + ", " + i4 + ", " + i5); | |
done = true; | |
} | |
++i; | |
} | |
function hasOnly01(s) { | |
for (let i = 0; i < s.length; ++i) { | |
if (s[i] != '0' && s[i] != '1') | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment