Python Fibonacci Generator

前端 未结 17 1339
别那么骄傲
别那么骄傲 2020-11-27 20:59

I need to make a program that asks for the amount of Fibonacci numbers printed and then prints them like 0, 1, 1, 2... but I can\'t get it to work. My code looks the followi

17条回答
  •  渐次进展
    2020-11-27 21:49

    i like this version:

    array = [0,1]
    
    for i in range(20):
       x = array[0]+array[1]   
       print(x)
       array[0] = array[1]
       array[1] = x
    

提交回复
热议问题