Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
'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
You can’t perform that action at this time.