Programming Examples

Python program that receives a Fibonacci series term and returns a number telling which term it is


Write a Python program that receives a Fibonacci series term and returns a number telling which term it is . for instance, if you pass 3, it return 5, telling it is 5th term; for 8, it returns 7.

Solution

fib=[]
a,b=-1,1
c=0
ind=int(input("Enter any Element : "))
while c<=ind:
    c=a+b
    fib.append(c)
    a,b=b,c
#print(fib)
print("Element  ",ind," Found at :",fib.index(ind)+1,"Position")
Output

Enter any Element : 8

Element   8  Found at : 7 Position

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz