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

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 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 Best Website and Software Company in Allahabad