#include #include #include "mpi.h" int main(int argc, char** argv) { int n = atoi(argv[1]), i; double total; MPI_Init( &argc, &argv ); total = 0.0; for(i = 1; i <= n; i++) { if(i % 4 == 1) { total += 1.0 / i; } else if (i % 4 == 3) { total -= 1.0 / i; } } printf("Pi = %.32f for %d iterations.\n", total * 4, n); MPI_Finalize(); return 0; }