Advertisement
Michal_Pilarski

zad26

Mar 22nd, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int liczba,a;
  5. int fib[100000];
  6. int fibonacci(int liczba)
  7. {
  8.     fib[0]=1;
  9.     fib[1]=1;
  10.     for(int i=2; i<liczba; i++)
  11.     {
  12.         fib[i] = fib[i-1] + fib[i-2];
  13.         a=fib[i];
  14.     }
  15.    return a;
  16. }
  17.  
  18. int main()
  19. {
  20.     cout << "Ktora liczbe ciagu fibonacciego chcesz znac?" << endl;
  21.     cin >> liczba;
  22.     cout<<"Jest to: "<<fibonacci(liczba);
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement