题解 | #Fibonacci#
Fibonacci
https://www.nowcoder.com/practice/17ad6908e36a49f4b06ea96936e8bb25
#include <iostream> #include<cstdio> using namespace std; int finonacci(int n){ if(n==0){ return 0; } else if(n==1){ return 1; } else{ return finonacci(n-1)+finonacci(n-2); } } int main() { int n; while(scanf("%d",&n)!=EOF){ printf("%d\n",finonacci(n)); } } // 64 位输出请用 printf("%lld")