Fibonacci
#include<iostream>
using namespace std;
int Fibonacci(int n){
if(n == 0) return 0;
else if(n == 1) return 1;
else return Fibonacci(n - 1) + Fibonacci(n - 2);
}
int main(){
int n;
while(scanf("%d", &n) != EOF){
printf("%d\n", Fibonacci(n));
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发