Last active
December 19, 2015 19:19
-
-
Save Zhangerr/6005391 to your computer and use it in GitHub Desktop.
cool little snippet in python to generate binary string (and recursive multiply)
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
binary = lambda n: n>0 and binary(n>>1)+[n&1] or [] | |
"".join(map(str,binary(10))) | |
def multiply(base, times): | |
if times == 0: | |
return 0 | |
return base + multiply(base, times-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment