+ 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

21st Feb 2021, 12:43 PM
Aditya Salabh
Aditya Salabh - avatar
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! :)
22nd Feb 2021, 1:23 AM
TheCoder
+ 1
TheCoder im searching elements in fibonacci search algorithm
23rd Feb 2021, 11:07 AM
Aditya Salabh
Aditya Salabh - avatar
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 :)
23rd Feb 2021, 4:24 PM
TheCoder