Skip to content

Commit 96072bf

Browse files
author
codehouseindia
authored
Merge pull request codehouseindia#20 from smallcityblues/patch-3
Python program to display the Fibonacci sequence
2 parents cb58c5a + 68af034 commit 96072bf

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

fibonaccisequence.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# https://www.facebook.com/tanishka.gupta.52090/posts/687845045495680
2+
# Subscribed by Tanishka Gupta
3+
4+
5+
def recur_fibo(n):
6+
if n <= 1:
7+
return n
8+
else:
9+
return(recur_fibo(n-1) + recur_fibo(n-2))
10+
11+
nterms = 10
12+
13+
# check if the number of terms is valid
14+
if nterms <= 0:
15+
print("Plese enter a positive integer")
16+
else:
17+
print("Fibonacci sequence:")
18+
for i in range(nterms):
19+
print(recur_fibo(i))

0 commit comments

Comments
 (0)