题解 | #Fibonacci#
Fibonacci
https://www.nowcoder.com/practice/17ad6908e36a49f4b06ea96936e8bb25
#include <iostream> using namespace std; //f1=1,f2=1,f3=2,f4=3 int main() { int n; while(cin >> n){ int a = 0, b = 1, c; if(n <= 1){ cout << n; } else{ for(int i = 2; i <= n; i++){ c = a + b; a = b; b = c; } cout << c; } } } // 64 位输出请用 printf("%lld")