题解 | #斐波那契数列#
斐波那契数列
http://www.nowcoder.com/practice/c6c7742f5ba7442aada113136ddea0c3
# -*- coding:utf-8 -*- class Solution: def Fibonacci(self, n): f1,f2,sum = 1,1,0 if n==0: return 0 if n <= 2: return f1 for i in range(n-2): sum = f1 + f2 f1 = f2 f2 = sum return sum # write code here num = int(input()) s = Solution() print(s.Fibonacci(num))