Skip to content

Instantly share code, notes, and snippets.

@erkobridee
Created February 3, 2012 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erkobridee/1730145 to your computer and use it in GitHub Desktop.
Save erkobridee/1730145 to your computer and use it in GitHub Desktop.
um dos desafios do site rankk.org
'''
The nth term
1,1,2,3,5,8,13,21,34,55,89 ...
Give the 119 th term.
'''
def fib(n):
a, b = 0, 1
r = []
while a < n:
r.append(a)
a, b = b, a+b
return r
print fib(90)
# [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
def nthTerm(n):
a, b = 55,89
n = n - 11
count = 0
while count < n:
a, b = b, a+b
count = count + 1
return b
print nthTerm(119)
# 3311648143516982017180081
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment