How to write the Fibonacci Sequence?

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

    def fib():
        a,b = 1,1
        num=eval(input("Please input what Fib number you want to be calculated: "))
        num_int=int(num-2)
        for i in range (num_int):
            a,b=b,a+b
        print(b)
    

提交回复
热议问题