Advertisement
kokokozhina

recurcion_12

Dec 10th, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream> //exercise 12, counting big sqrt
  2.  
  3. using namespace std;
  4.  
  5. double moreSqrt(int n, int m = 1)
  6. {
  7.     if (m == n)
  8.         return 1;
  9.     else
  10.         return sqrt(1 + (m + 1) * moreSqrt(n, m + 1));
  11. }
  12.  
  13.  
  14. int main()
  15. {
  16.     int n;
  17.     cout << "Enter the value of N: ";
  18.     cin >> n;
  19.     cout << "Your big sqrt is " << moreSqrt(n) << endl;
  20.     system("pause");
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement