Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- long long vetor[5005];
- int main(){
- //freopen("in.txt", "r", stdin);
- //freopen("out.txt", "w", stdout);
- int n, nAnt = 2;
- while(cin>>n){
- vetor[1] = 1;
- for(int i = nAnt; i<=n; i++){
- vetor[i] = vetor[i-1]+vetor[i-2];
- }
- if(n>nAnt)nAnt = n;
- cout<<"The Fibonacci number for "<<n<<" is "<<vetor[n]<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment