Advertisement
fryc1906

rekurencja1

Nov 15th, 2017
342
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. using namespace std;
  3.  
  4. int funkcja(int n)
  5. {
  6.     if(n==0) return 1;        
  7.     return funkcja(n-2)*n;
  8. }
  9.  
  10. int main()
  11. {
  12.     int n;
  13.     cout<<"Podaj n z przedzialu <2;30>"<<endl;
  14.     cin>>n;
  15.     if(n<=30)
  16.     {        
  17.         n=n-(n%2);
  18.         cout<<funkcja(n)<<endl;
  19.     }
  20.     else
  21.     {
  22.         cout<<"Podales n wieksze niz 30";
  23.     }
  24.     cin.ignore();
  25.     getchar();
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement