title: Finding the Square Root with recursion in Java
body: <p>I have to write a program that returns the square root of any number that is inputted. My method runs fine for any number that has a perfect square (like 25 or 100) but if I use any number that doesn't (3 or 10) I get a stack overflow error. I was hoping some one could tell me what I did wrong and how I could fix it. </p>
  
  <pre><code>   public boolean sqrRootRecursive(int number, double approx, double tol)
  {
  
      if( (Math.abs((Math.pow(approx,2) - number))&lt;= tol))
      {
         System.out.println("The root is " +approx);
      }else if (Math.abs((Math.pow(approx,2)-number))&gt;tol)
      {
          sqrRootRecursive(number, ((Math.pow(approx,2)+number)/(2*approx)), tol); 
      }
  
  
     return true; 
  </code></pre>
  
  <p>Thanks for the help!</p>