Advertisement
myname0

rec_38_II_2

Mar 17th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. static double rec(int n )
  6. {
  7.    
  8.     if (n < 1) return 0;
  9.     return n == 1 ? 5 : rec(n - 1) /((n-1) * (n-1) + n);
  10. }
  11.  int main()
  12.  
  13.  {
  14.          int b1 = 5;
  15.          int n;
  16.          cout << " Enter number of element: ";
  17.          cin >> n;
  18.          double bn;
  19.          bn = rec (n);
  20.          if(bn == 0)
  21.              cout << "Incorrect number of elements!";
  22.          else cout << " n-elrment: " << bn;
  23.         return 0;
  24.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement