Created
February 1, 2017 05:00
-
-
Save rawsh/329fc9d83338ed9bea6c97f5566ed2fe to your computer and use it in GitHub Desktop.
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
| import sys | |
| known = {0:1,1:1,2:1} | |
| def sequence(n): | |
| if n in known: | |
| return known[n] | |
| else: | |
| x = 2*sequence(n-1) + 2*sequence(n-2) + 2*sequence(n-3) | |
| known[n] = x | |
| return x | |
| def ratio(n): | |
| x = sequence(n) | |
| y = sequence(n-1) | |
| return x/float(y) | |
| sys.setrecursionlimit(150000) | |
| for x in range(3,100): | |
| print ratio(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment