Format code with prettier (#3375)

This commit is contained in:
acbin
2022-10-03 17:23:00 +08:00
committed by GitHub
parent 32b9b11ed5
commit e96f567bfc
464 changed files with 11483 additions and 6189 deletions

View File

@@ -22,18 +22,25 @@ 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;
int divCounter = 2;
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;