How to write the Fibonacci Sequence?

前端 未结 30 2824
醉酒成梦
醉酒成梦 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:15

    Why not simply do the following?

    x = [1,1]
    for i in range(2, 10):  
        x.append(x[-1] + x[-2]) 
    print(', '.join(str(y) for y in x))
    

提交回复
热议问题