How to write the Fibonacci Sequence?

前端 未结 30 2652
醉酒成梦
醉酒成梦 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条回答
  •  余生分开走
    2020-11-22 01:28

    Basically translated from Ruby:

    def fib(n):
        a = 0
        b = 1
        for i in range(1,n+1):
                c = a + b
                print c
                a = b
                b = c
    

    ...

提交回复
热议问题