Skip to content

Instantly share code, notes, and snippets.

@Zhangerr
Last active December 19, 2015 19:19
Show Gist options
  • Save Zhangerr/6005391 to your computer and use it in GitHub Desktop.
Save Zhangerr/6005391 to your computer and use it in GitHub Desktop.
cool little snippet in python to generate binary string (and recursive multiply)
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