Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Curso explicación fib.
def fib(n):
if n < 2:
return n
else:
return fib(n-1) + fib(n-2)
def fib_seq(n):
"""
Calcula la secuencia de fibonacci hasta n
Ejemplo:
>>> fib_seq(10)
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
"""
res = []
for i in range(1, n+1):
res.append(fib(i))
return res
n = 10
res = fib_seq(n)
print('La secuencia Fibbonaci hasta %s es: %s' % (n, res))
print([fib(i)**3 for i in range(1, n+1)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.