Created
March 12, 2017 11:58
-
-
Save enil/3c54612dcaf934ba1a813662b9554a0d to your computer and use it in GitHub Desktop.
Recursive conversion to a binary string
This file contains hidden or 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
function binToString(n) { | |
if (n <= 1) { | |
return String(n); | |
} else { | |
return binToString(n >> 1) + binToString(n & 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment