Advertisement
MeehoweCK

Untitled

Aug 20th, 2019
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void fibonacci(unsigned n)
  6. {
  7.     unsigned a, b = 0, c = 1, licznik = 0;
  8.     cout << endl;
  9.     while(licznik < n)
  10.     {
  11.         cout << c << '\t';
  12.         a = b;
  13.         b = c;
  14.         c = a + b;
  15.         ++licznik;
  16.     }
  17.     cout << endl;
  18. }
  19.  
  20. int main()
  21. {
  22.     unsigned n;
  23.  
  24.     cout << "Podaj liczbe elementow ciagu Fibonacciego: ";
  25.     cin >> n;
  26.  
  27.     fibonacci(n);
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement