From 3eba4c996c3d301fef429d34111a42d5b1c5d90e Mon Sep 17 00:00:00 2001 From: Sanskar Date: Fri, 2 Oct 2020 01:56:59 +0530 Subject: [PATCH 1/2] Delete fibo.py --- fibo.py | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 fibo.py diff --git a/fibo.py b/fibo.py deleted file mode 100644 index 4361cce..0000000 --- a/fibo.py +++ /dev/null @@ -1,13 +0,0 @@ -def fib(n): # write Fibonacci series up to n - a, b = 0, 1 - while b < n: - print b, - a, b = b, a+b - -def fib2(n): # return Fibonacci series up to n - result = [] - a, b = 0, 1 - while b < n: - result.append(b) - a, b = b, a+b - return result From ad061b819338db78e8c29450034ed4416dc6f5fa Mon Sep 17 00:00:00 2001 From: Sanskar Date: Fri, 2 Oct 2020 01:57:23 +0530 Subject: [PATCH 2/2] Add files via upload --- fibonacci.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 fibonacci.py diff --git a/fibonacci.py b/fibonacci.py new file mode 100644 index 0000000..7087a04 --- /dev/null +++ b/fibonacci.py @@ -0,0 +1,12 @@ +FibArray = [0,1] +def fibonacci(n): + if n<=0: + print("Incorrect input") + elif n<=len(FibArray): + return FibArray[n-1] + else: + temp_fib = fibonacci(n-1)+fibonacci(n-2) + FibArray.append(temp_fib) + return temp_fib +x=int(input()) +print(fibonacci(x)) \ No newline at end of file