Advertisement
MeehoweCK

Untitled

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