#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param n int整型
# @return int整型
#
class Solution:
def Fibonacci(self , n: int) -> int:
# write code here
if n==1 or n==2:
return 1
else:
# return Solution().Fibonacci(n-1)+Solution().Fibonacci(n-2)
# 根据定义
a,b=0,1
for i in range(n-1):
a,b=b,a+b
return b

京公网安备 11010502036488号