Created
January 5, 2014 20:01
-
-
Save RuedigerMoeller/8273032 to your computer and use it in GitHub Desktop.
calc PI slice
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
static double calculatePiFor(int slice, int nrOfIterations) { | |
double acc = 0.0; | |
for (int i = slice * nrOfIterations; i <= ((slice + 1) * nrOfIterations - 1); i++) { | |
acc += 4.0 * (1 - (i % 2) * 2) / (2 * i + 1); | |
} | |
return acc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment