Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int fact(int n) {
- if (n == 0) return 1;
- return n * fact(n - 1);
- }
- double sum(int n) {
- /*int s = 0;
- while(n>0){
- s += (2.0 * n )/ ((2.0 * n - 1) * fact(2.0 * n + 2.0));
- n--;
- }*/
- if (n == 1) return (2/(3*fact(4)));
- return ((2*n)/(((2 * n) - 1) * fact((2 * n) + 2)))+ sum(n-1);
- //return s;
- }
- int main(){
- cout<<fact(3)<<endl;
- cout << (double)sum(1)<<endl;
- cout << (double)sum(2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement