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

@@ -22,9 +22,7 @@ public class PiNilakantha {
*/
public static double calculatePi(int iterations) {
if (iterations < 0 || iterations > 500) {
throw new IllegalArgumentException(
"Please input Integer Number between 0 and 500"
);
throw new IllegalArgumentException("Please input Integer Number between 0 and 500");
}
double pi = 3;
@@ -32,15 +30,9 @@ public class PiNilakantha {
for (int i = 0; i < iterations; i++) {
if (i % 2 == 0) {
pi =
pi +
4.0 /
(divCounter * (divCounter + 1) * (divCounter + 2));
pi = pi + 4.0 / (divCounter * (divCounter + 1) * (divCounter + 2));
} else {
pi =
pi -
4.0 /
(divCounter * (divCounter + 1) * (divCounter + 2));
pi = pi - 4.0 / (divCounter * (divCounter + 1) * (divCounter + 2));
}
divCounter += 2;