题目描述:输出对应的第几项数值。
代码如下:
class Solution {
public:
/**
* @param n: an integer
* @return: an ineger f(n)
*/
int fibonacci(int n) {
// write your code here
int a = 0, b = 1;
for(int i = 1; i < n; i++)
{
int c = a + b;
a = b;
b = c;
}
return a;
}
};