Advertisement
pan7nikt

Fibonacci

Feb 25th, 2020
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. unsigned input;
  5. int i;
  6.  
  7. int fb(int a)
  8. {
  9.     int tab[a];
  10.     cout << "0";
  11.     tab[0] = 0;
  12.     cout << "1";
  13.     tab[1] = 1;
  14.     for (i=2;i<a;i++)
  15.     {
  16.         tab[i] = tab[i-1] + tab[i-2];
  17.         cout << i << ". " << tab[i] << endl;
  18.        
  19.     }
  20. }
  21.  
  22.  
  23. int main()
  24. {
  25.     cout << "podaj ile wyrazow ciagu chcesz wyswietlic: ";
  26.     cin >> input;
  27.     fb(input);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement