+ 2
FIBONACCI SEARCH PROBLEM
Im not getting the desired result.... Like if i input data:12.... Function should give the output as not present,but it is giving found..... Chek here https://code.sololearn.com/c3A24a129a17/?ref=app
3 Respuestas
+ 1
Umm, sorry I didn't catch you. What is your desired result? Are you making a Fiboacci pattern up to a certain number or checking if a number is in the Fibonacci series? 🤔🤔🤔
Anyways, thanks for your question! :)
+ 1
TheCoder im searching elements in fibonacci search algorithm
0
Aditya Salabh it should go something like this:
a = 1
b = 1
number = int(input("Number?"))
fibolist = []
while True:
b += a
fibolist.append(a)
a += b
fibolist.append(b)
if fibolist[-1] > number:
break
isfibo = False
for i in fibolist:
if i == number:
isfibo = True
if isfibo == True:
print("Number is in the Fibonacci series!")
else:
print("Number is not in the Fibonacci series")
print("Fibonacci :", fibolist)
Hope it works! Happy programming :)