From 230ef2c8c435aca0999ba59e019b01ba018bb685 Mon Sep 17 00:00:00 2001 From: Shweta Goyal <36664302+Shwetago@users.noreply.github.com> Date: Thu, 4 Oct 2018 13:08:02 +0530 Subject: [PATCH 1/2] Fibonacci series in python --- fibonacci.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 fibonacci.py diff --git a/fibonacci.py b/fibonacci.py new file mode 100644 index 0000000..c4b61d5 --- /dev/null +++ b/fibonacci.py @@ -0,0 +1,23 @@ +Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32 +Type "copyright", "credits" or "license()" for more information. +>>> def fib(n): + if(n == 0): + return 0 + elif(n == 1): + return 1 + else: + return(fib(n-1) + fib(n-2)) + + +>>> n = int(input("Enter number of terms: ")) +Enter number of terms: 5 +>>> for i in range(n): + print(fib(i)) + + +0 +1 +1 +2 +3 +>>> From 2b80c030314dfe81d409cf0431b45fdea459098a Mon Sep 17 00:00:00 2001 From: Shweta Goyal <36664302+Shwetago@users.noreply.github.com> Date: Thu, 4 Oct 2018 13:13:36 +0530 Subject: [PATCH 2/2] Update fibonacci.py --- fibonacci.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fibonacci.py b/fibonacci.py index c4b61d5..1d6fd2f 100644 --- a/fibonacci.py +++ b/fibonacci.py @@ -1,5 +1,5 @@ -Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32 -Type "copyright", "credits" or "license()" for more information. +Python 3.6.5 (v3.6.5:f59c0932b4) on win32 + >>> def fib(n): if(n == 0): return 0