Skip to content

Instantly share code, notes, and snippets.

@JJ
Created June 29, 2017 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JJ/c8721a62f552e5aa019c18d7e0dbb65e to your computer and use it in GitHub Desktop.
Save JJ/c8721a62f552e5aa019c18d7e0dbb65e to your computer and use it in GitHub Desktop.
Test for powers of 2 using bitwise operators
print(list(filter( lambda pow2: pow2^(pow2-1) > pow2, range(1000))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment