Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double calc(int y, int);
- int main()
- {
- double x;
- int n;
- cout << "Enter n: " << endl;
- cin >> n;
- int i = 1;
- x = calc(n, i);
- cout << "Your result: " << x << endl;
- return 0;
- }
- double calc(int y, int i)
- {
- double rez = 0;
- if (i >= y)
- {
- rez = 1+1./3;
- }
- else
- {
- rez = i + (1./calc(y, (i + 2)));
- }
- return rez;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement