Skip to content

Commit 12ece68

Browse files
authored
Update practice.py
1 parent 225147c commit 12ece68

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bits_wilp/practice.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,15 @@ def fibo_iter(n_terms):
4848
print(result, end=' ')
4949

5050
fibo_iter(5) # 0 1 1 2 3
51+
52+
def fibo_recur(n):
53+
if n == 0:
54+
return 0
55+
elif n == 1:
56+
return 1
57+
else:
58+
return fibo_recur(n-1) + fibo_recur(n-2)
59+
60+
61+
for i in range(0, 10):
62+
print(fibo_recur(i), end=' ') # 0 1 1 2 3 5 8 13 21 34

0 commit comments

Comments
 (0)