Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int factorial (int s, int d)
- {
- if (s==d)
- return s;
- else {
- int m=(s+d)/2;
- return factorial(s, m)*factorial(m+1, d);
- }
- }
- int e (int s, int d)
- {
- if (s==d)
- return factorial(1, s);
- else {
- int m=(s+d)/2;
- return e(s, m)+e(m+1, d);
- }
- }
- int main()
- {
- int n;
- cin>>n;
- cout<<e(1, n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement