Skip to content

Instantly share code, notes, and snippets.

@azz
Last active August 29, 2015 14:04
Show Gist options
  • Save azz/29b9c84508106e1aaf15 to your computer and use it in GitHub Desktop.
Save azz/29b9c84508106e1aaf15 to your computer and use it in GitHub Desktop.
Prints the first 10 Lucas Numbers
print "━".join([reduce(lambda x,n: [x[1], x[0]+x[1]], range(i), [2,1])[0] *'┃' for i in range(10)])
# 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