Advertisement
fryc1906

rekurencja2

Nov 15th, 2017
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int funkcja(int n)
  5. {
  6.     if(n==1 || n==2) return 1;        
  7.     return funkcja(n-1)+funkcja(n-2);
  8. }
  9.  
  10. int main()
  11. {
  12.     int n;
  13.     cout<<"Podaj n"<<endl;
  14.     cin>>n;
  15.     cin.ignore();
  16.     cout<<n<<" wyraz ciagu Fibonnaciego wynosi: "<<funkcja(n)<<endl;
  17.     getchar();
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement