斐波那契
程序员文章站
2022-03-31 21:37:06
...
# -*- coding:utf-8 -*-
class Solution:
def Fibonacci(self, n):
# write code her
if n <= 1:
return n
if n == 2:
return 1
a = 1
b = 1
sum = 0
for i in range(n-2):
sum = a + b
a = b
b = sum
return sum
上一篇: 具体介绍HTML5表单新增属性