Last active
September 9, 2018 03:14
-
-
Save alex-polosky/dcc90b77e514eee49810e77570591e9d to your computer and use it in GitHub Desktop.
Check here for inspiration: https://www.youtube.com/watch?v=z1THaBtc5RE&feature=youtu.be
This file contains 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
from math import sqrt | |
def arb(n, A, B): | |
return ((sqrt(5) + 1) / 2) ** n * ((3 * sqrt(5) - 5) * A + (5 - sqrt(5)) * B) / 10 | |
def gen(l, A, B): | |
return [(n, int(round(arb(n, A, B)))) for n in range(l)] | |
def pprint(l, A, B): | |
for each in gen(l, A, B): | |
print("{0}: {1}".format(*each)) | |
# Example: | |
# pprint(20, 1, 1): | |
# 0: 0 | |
# 1: 1 | |
# 2: 1 | |
# 3: 2 | |
# 4: 3 | |
# 5: 5 | |
# 6: 8 | |
# 7: 13 | |
# 8: 21 | |
# 9: 34 | |
# 10: 55 | |
# 11: 89 | |
# 12: 144 | |
# 13: 233 | |
# 14: 377 | |
# 15: 610 | |
# 16: 987 | |
# 17: 1597 | |
# 18: 2584 | |
# 19: 4181 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment