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 0ae0092 commit 974110fCopy full SHA for 974110f
fibonacci/python/Fibonacci-with-Recursion.py
@@ -0,0 +1,15 @@
1
+def fibo(n):
2
+ # if n is 1 return 1
3
+ if n == 1:
4
+ return 1
5
+ # if n is 2 still return 1
6
+ elif n == 2:
7
8
+ # else return the sum of last to terms
9
+ elif n > 2:
10
+ return fibo(n-1) + fibo(n-2)
11
+
12
+# for loop for sum fibonacci numbers upto n
13
+for i in range(1, 10):
14
+ # printing fibonacci numbers according to term number
15
+ print(i, ":", fibo(i))
0 commit comments