Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. double x;
  6. const double PI=3.141459265;
  7.  
  8. double f(double i)
  9. {
  10. if (i<=1) return ((2*x)/(pow(x,2)-PI));
  11. else return (f(i-1)*((pow(x,2)-(i-1)*pow(PI,(i-1)))/(pow(x,2)-i*pow(PI,i))));
  12. }
  13.  
  14. int main() {
  15.     double n;
  16.     double S;
  17.     cout << "x = ";
  18.     cin >> x;
  19.     cout << "n = ";
  20.     cin >> n;
  21.     S=(1/x)+f(n);
  22.     cout << "S = " << S;
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement