Advertisement
JoannaDobrowolska

Zadanie 26

Mar 31st, 2020
93
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. int FIBONACCI(int n);
  6.  
  7. int main()
  8. {
  9.     int n;
  10.  
  11.     cout << "Podaj numer wyrazu ciagu Fibonacciego (Fn):" << endl;
  12.     cin >> n;
  13.  
  14.     cout <<"Wyraz ten wynosi: "<<FIBONACCI(n) << endl;
  15.     return 0;
  16. }
  17.  
  18. int FIBONACCI(int n)
  19. {
  20.     if(n==0) return 0;
  21.     if(n==1) return 1;
  22.     return FIBONACCI(n-1)+FIBONACCI(n-2);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement