We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 186842e commit 35d51d0Copy full SHA for 35d51d0
Data Strucrures/Recursion.py
@@ -0,0 +1,18 @@
1
+# Program to print the fibonacci series upto n_terms
2
+
3
+# Recursive function
4
+def recursive_fibonacci(n):
5
+ if n <= 1:
6
+ return n
7
+ else:
8
+ return(recursive_fibonacci(n-1) + recursive_fibonacci(n-2))
9
10
+n_terms = 10
11
12
+# check if the number of terms is valid
13
+if n_terms <= 0:
14
+ print("Invalid input ! Please input a positive value")
15
+else:
16
+ print("Fibonacci series:")
17
+ for i in range(n_terms):
18
+ print(recursive_fibonacci(i))
0 commit comments