Advertisement
VictoriaLodochkina

lab 11 z1 FATAL ERROR

Jan 12th, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. double calc(int y, int);
  7.  
  8. int main()
  9. {
  10.     double x;
  11.     int n;
  12.     cout << "Enter n: " << endl;
  13.     cin >> n;
  14.     int i = 1;
  15.     x = calc(n, i);
  16.     cout << "Your result: " << x << endl;
  17.     return 0;
  18. }
  19.  
  20.  double calc(int y, int i)
  21. {
  22.     double rez = 0;
  23.     if (i >= y)
  24.     {
  25.         rez = 1+1./3;
  26.     }
  27.     else
  28.     {
  29.         rez = i + (1./calc(y, (i + 2)));
  30.     }
  31.     return rez;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement