Skip to content

Instantly share code, notes, and snippets.

@stanroze
Created April 10, 2013 19:09
Show Gist options
  • Save stanroze/5357534 to your computer and use it in GitHub Desktop.
Save stanroze/5357534 to your computer and use it in GitHub Desktop.
public double Sqrt(double a, int times)
{
if (a < 0)
throw new Exception("Can not sqrt a negative number");
double x = 1;
while (times-- > 0)
x = x / 2 + a / (2 * x);
return x;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment