#include <bits/stdc++.h>
using namespace std;
//递归
int handle1(int N){
if(N == 1) return 1;
if(N == 2) return 2;
if(N > 2){
return handle1(N-1)+handle1(N-2);
}
return 0;
}
//斐波那契数列
int handle2(int n){
n = n + 1;
return (1/sqrt(5))*(pow((1+sqrt(5))/2,n)-pow((1-sqrt(5))/2,n)) ;
}
int main(){
int N;
while(scanf("%d",&N)!=EOF){
printf("%d\n",handle1(N));
printf("%d\n",handle2(N));
}
return 0;
}
走10级楼梯题目解法总结
猜你喜欢
转载自blog.csdn.net/bojie5744/article/details/51189870
今日推荐
周排行