Last active
August 29, 2015 14:04
-
-
Save azz/29b9c84508106e1aaf15 to your computer and use it in GitHub Desktop.
Prints the first 10 Lucas Numbers
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 "━".join([reduce(lambda x,n: [x[1], x[0]+x[1]], range(i), [2,1])[0] *'┃' for i in range(10)]) |
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
# Much more efficient than above | |
def lucas(num): | |
l,u = 2,1 | |
for i in range(num): | |
yield l | |
l,u = u,l+u | |
print "━".join([a*'┃' for a in lucas(10)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment