Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fib_intervall(x):
- """ returns the largest fibonacci
- number smaller than x and the lowest
- fibonacci number higher than x"""
- if x < 0:
- return -1
- (old,new, lub) = (0,1,0)
- while True:
- if new < x:
- lub = new
- (old,new) = (new,old+new)
- else:
- return (lub, new)
- while True:
- x = int(input("Your number: "))
- if x <= 0:
- break
- (lub, sup) = fib_intervall(x)
- print("Largest Fibonacci Number smaller than x: " + str(lub))
- print("Smallest Fibonacci Number larger than x: " + str(sup)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement