Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <time.h>
- #include <omp.h>
- using namespace std;
- int main()
- {
- double N = 86000000, sum = 0.0;
- clock_t t1, t2;
- double time, total = 0.0;
- int n = 1;
- t1 = clock();
- #pragma omp parallel for private(n,sum) reduction(+:total)
- for(n = 1; n <= N; n++)
- {
- sum = pow(-1, n) / (pow((2 * n + 1), 3) - 1);
- total += sum;
- }
- t2 = clock();
- time = (t2 - t1) / (double)CLOCKS_PER_SEC;
- cout << time << endl <<total;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement