Advertisement
Statis

Ex 3

Nov 13th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 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 e (int s, int d)
  13. {
  14. if (s==d)
  15. return factorial(1, s);
  16. else {
  17. int m=(s+d)/2;
  18. return e(s, m)+e(m+1, d);
  19. }
  20. }
  21. int main()
  22. {
  23. int n;
  24. cin>>n;
  25. cout<<e(1, n);
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement