MeehoweCK

Untitled

Aug 16th, 2022
697
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.  
  3. using namespace std;
  4.  
  5. void fibonacci(int ile)
  6. {
  7.     int a = 0, b = 1, c = 0;
  8.     for(int i = 0; i < ile; ++i)
  9.     {
  10.         a = b;
  11.         b = c;
  12.         c = a + b;
  13.         cout << c << '\t';
  14.     }
  15. }
  16.  
  17. int main()
  18. {
  19.     int liczba;
  20.     cout << "Podaj liczbe naturalna: ";
  21.     cin >> liczba;
  22.  
  23.     fibonacci(liczba);
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment