Skip to content

Instantly share code, notes, and snippets.

@RuedigerMoeller
Created January 5, 2014 20:01
Show Gist options
  • Save RuedigerMoeller/8273032 to your computer and use it in GitHub Desktop.
Save RuedigerMoeller/8273032 to your computer and use it in GitHub Desktop.
calc PI slice
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