RafalSobala

zad 26

Mar 31st, 2020
137
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. int x;
  5.  
  6. void fibonacci(int x)
  7. {
  8.      long long a = 0, b = 1;
  9.  
  10.      for(int i=0;i<x;i++)
  11.      {
  12.             cout<<b<<" ";
  13.             b = a+b;
  14.             a = b-a;
  15.      }
  16. }
  17.  
  18. int main()
  19. {
  20.  
  21.     cout<<"Podaj do którego wyrazu ciągu fibonacciego podać wartość: ";
  22.     cin>>x;
  23.  
  24.     fibonacci(x);
  25.  
  26.     return 0;
  27. }
Add Comment
Please, Sign In to add comment