Skip to content
Snippets Groups Projects
Commit 98a425c8 authored by Martin Mareš's avatar Martin Mareš
Browse files

Fibonacci: Další řešení

parent 8b07c25c
Branches
No related tags found
No related merge requests found
......@@ -7,3 +7,17 @@ def fibonacci(n):
for i in range(2, n+1):
a, b = b, a+b
return b
def fibonacci2(n):
fib = [0, 1]
while len(fib) <= n:
fib.append(fib[-1] + fib[-2])
return fib[n]
def fibonacci3(n):
if n <= 1:
return n
else:
return fibonacci3(n-1) + fibonacci3(n-2)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment