style: format code (#4212)

close #4204
This commit is contained in:
acbin
2023-06-09 18:52:05 +08:00
committed by GitHub
parent ad03086f54
commit 00282efd8b
521 changed files with 5233 additions and 7309 deletions

View File

@@ -19,11 +19,13 @@ import java.util.Scanner;
public class SquareRootWithNewtonRaphsonMethod {
public static double squareRoot(int n) {
double x = n; //initially taking a guess that x = n.
double root = 0.5 * (x + n / x); //applying Newton-Raphson Method.
double x = n; // initially taking a guess that x = n.
double root = 0.5 * (x + n / x); // applying Newton-Raphson Method.
while (Math.abs(root - x) > 0.0000001) { //root - x = error and error < 0.0000001, 0.0000001 is the precision value taken over here.
x = root; //decreasing the value of x to root, i.e. decreasing the guess.
while (
Math.abs(root - x) > 0.0000001) { // root - x = error and error < 0.0000001, 0.0000001
// is the precision value taken over here.
x = root; // decreasing the value of x to root, i.e. decreasing the guess.
root = 0.5 * (x + n / x);
}