How to write the Fibonacci Sequence?

前端 未结 30 2383
醉酒成梦
醉酒成梦 2020-11-22 00:32

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

30条回答
  •  梦毁少年i
    2020-11-22 01:05

    Maybe this will help

    def fibo(n):
        result = []
        a, b = 0, 1
        while b < n:
                result.append(b)
                a, b = b, b + a
        return result
    

提交回复
热议问题