C++/代码:

class Solution {
public:
    int Fibonacci(int n) {
        int a = 0,b = 1; //第0项为0.第1项为1
        while(n --) { //先执行后减
            int c = a + b; 
            a = b, b = c;
        }
        return a ; 
    }
};