Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(0, "rus");
- int n;
- double Root_R(int);
- double Root(int);
- cout << "Введите число n:" << endl;
- cin >> n;
- cout << "Это рекурсия: \t\t" << Root_R(n) << endl;
- cout << "Это не рекурсия:\t" << Root(n) << endl;
- }
- double Root_R(int n)
- {
- if (n < 2) return 1;
- else
- return sqrt(sqrt(n) + Root_R(n - 1));
- }
- double Root(int n)
- {
- double y = 0, z = 0;
- for (int i = n; i > 0; i--)
- {
- y = sqrt(z + i);
- z = y;}
- return y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement