Calculate the nth term in fibonacci sequence using python

 


Hey guys once again welcome to the Decoders blog, I hope you all are doing well and today I'm present with fibonacci sequence  calculator(to find the nth term of the fibonacci sequence) which you can create using python, The given code will help you to built it, so just follow the codes and make your fibonacci sequence calculations easily  , and enjoy it while solving maths   

#fibonnaci numbers :It is a sequence of numbers starting from 0 and 1 in which
 the next number is the sum of the previous two numbers
#NOTE you can start the index from 0 and 1 in this example i have started with1
# for e.g:0,1,1,2,3,5,8,13.........
def fibonnaci(n):
if n==1:
return 0
elif n==2:
return 1
else:
return fibonnaci(n-1)+fibonnaci(n-2)
n=int(input("enter the number: \n"))
print(fibonnaci(n))

 

Comments

Popular Posts