Advertisement
makispaiktis

Fibonacci

Apr 20th, 2019 (edited)
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. void displayVector(vector <int> v){
  8.     for(unsigned int i=0; i<v.size(); i++){
  9.         cout << v[i] << endl;;
  10.     }
  11. }
  12.  
  13. int main()
  14. {
  15.     vector <int> fibo = vector <int> ();
  16.     fibo.push_back(1);
  17.     fibo.push_back(1);
  18.     int size1 = 46;
  19.     for(int i=2; i<size1; i++){
  20.         fibo.push_back(fibo[i-1] + fibo[i-2]);
  21.     }
  22.     displayVector(fibo);
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement