Created
April 10, 2013 19:09
-
-
Save stanroze/5357534 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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