#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
long long ans;int n;
vector <long long> fib;
while(cin >> n){
if(n == 0)break;
fib.push_back(0);fib.push_back(1);
for(int i = 1; i <= n; i++){
ans = fib[i-1] + fib[i];
fib.push_back(ans);
}
cout << ans << endl;fib.clear();
}
return 0;
}
#include <algorithm>
#include <vector>
using namespace std;
int main(){
long long ans;int n;
vector <long long> fib;
while(cin >> n){
if(n == 0)break;
fib.push_back(0);fib.push_back(1);
for(int i = 1; i <= n; i++){
ans = fib[i-1] + fib[i];
fib.push_back(ans);
}
cout << ans << endl;fib.clear();
}
return 0;
}
No comments:
Post a Comment