2018-10-02 18:14:53 +05:30
|
|
|
# Fibonacci Sequence Using Recursion
|
|
|
|
|
|
|
|
|
|
def recur_fibo(n):
|
|
|
|
|
if n <= 1:
|
|
|
|
|
return n
|
|
|
|
|
else:
|
|
|
|
|
return(recur_fibo(n-1) + recur_fibo(n-2))
|
|
|
|
|
|
2018-10-07 15:52:34 -07:00
|
|
|
limit = int(input("How many terms to include in fibonacci series: "))
|
2018-10-02 18:14:53 +05:30
|
|
|
|
|
|
|
|
if limit <= 0:
|
2018-10-07 15:52:34 -07:00
|
|
|
print("Please enter a positive integer: ")
|
2018-10-02 18:14:53 +05:30
|
|
|
else:
|
2018-10-07 15:52:34 -07:00
|
|
|
print(f"The first {limit} terms of the fibonacci series are as follows")
|
2018-10-02 18:14:53 +05:30
|
|
|
for i in range(limit):
|
|
|
|
|
print(recur_fibo(i))
|