From 44846ec97311f5e253ab5eff76ebcca2ad622460 Mon Sep 17 00:00:00 2001 From: Jayes Lokhande Date: Thu, 3 Oct 2019 18:00:05 +0530 Subject: [PATCH] fibonacci series in python --- python/fibo.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 python/fibo.py diff --git a/python/fibo.py b/python/fibo.py new file mode 100644 index 0000000..49e19f3 --- /dev/null +++ b/python/fibo.py @@ -0,0 +1,20 @@ +# Function for nth Fibonacci number + +def Fibonacci(n): + if n<0: + print("Incorrect input") + # First Fibonacci number is 0 + elif n==1: + return 0 + # Second Fibonacci number is 1 + elif n==2: + return 1 + else: + return Fibonacci(n-1)+Fibonacci(n-2) + +# Driver Program + +print(Fibonacci(9)) + +#This code is contributed by Saket Modi +