Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions 01_fibo_prob.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@ def get_nth_fibo_num(n):
get_nth_fibo_num(10) should return 55
"""
n = int(n)
if n == 1:
return 1
return get_nth_fibo_num(n-1)+get_nth_fibo_num(n-2)
count = 2
a = 0
b = 1
while count <= n:
c = a+b
a = b
b = c
count += 1
return c
# if n == 1:
# return 1
# return get_nth_fibo_num(n-1)+get_nth_fibo_num(n-2)

try:
if len(sys.argv) < 2:
Expand Down