Statis

Ex 1

Nov 13th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int factorial (int s, int d)
  4. {
  5.     if (s==d)
  6.         return s;
  7.     else {
  8.         int m=(s+d)/2;
  9.         return factorial(s, m)*factorial(m+1, d);
  10.     }
  11. }
  12. int main()
  13. {
  14.     int n;
  15.     cin>>n;
  16.     cout<<factorial(1, n);
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment