Created
June 29, 2017 16:15
-
-
Save JJ/c8721a62f552e5aa019c18d7e0dbb65e to your computer and use it in GitHub Desktop.
Test for powers of 2 using bitwise operators
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
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