I had originally coded the program wrongly. Instead of returning the Fibonacci numbers between a range (ie. startNumber 1, endNumber 20 should = only those numbers between 1
OK.. after being tired of referring all lengthy answers, now find the below sort & sweet, pretty straight forward way for implementing Fibonacci in python. You can enhance it it the way you want by getting an argument or getting user input…or change the limits from 10000. As you need……
def fibonacci():
start = 0
i = 1
lt = []
lt.append(start)
while start < 10000:
start += i
lt.append(start)
i = sum(lt[-2:])
lt.append(i)
print "The Fibonaccii series: ", lt
This approach also performs good. Find the run analytics below
In [10]: %timeit fibonacci
10000000 loops, best of 3: 26.3 ns per loop