输入一个整数 n ,求斐波那契数列的第 n 项。
假定从 0 开始,第 0 项为 0。
class Solution { public: int Fibonacci(int n) { if (n < 2) return n; int a = 0, b = 1, c; for (int i = 2; i <= n; i++) { c = a + b; a = b, b = c; } return c; } };
标签:求斐波,return,数列,int,斐波,那契 From: https://www.cnblogs.com/leetothemoon/p/16971871.html