Created
July 31, 2015 01:32
-
-
Save saxbophone/54be375dd33607ab2bb5 to your computer and use it in GitHub Desktop.
Having some fun with Python Generators...
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
| def fibonacci(a=0, b=1): | |
| yield a | |
| yield b | |
| while True: | |
| a = a+b | |
| yield a | |
| b = b+a | |
| yield b | |
| def fibo_hash(m, a=0, b=1): | |
| for f in fibonacci(a=a, b=b): | |
| if f.bit_length() >= m: | |
| return '%x' % f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment