If a sequence of numbers follows a pattern of adding a fixed amount from one term to the next, it is referred to as an arithmetic sequence. The sum of its terms is called an arithmetic series. The following examples are all arithmetic series:
11+2+3+4+5+...+n-2+n-1+n=k (1-+==1-+++++++0+1
In General
S=a+a+a+a+...+a+...+a=n*a
=a+a+d+a+2d+a+3d+a+4d+...+a+n-1d=n*a1+k-1d
(1)
a=a+(k-1)d
a is the first element in the arithmetic sequence.
d is the constant difference between consecutive elements in the arithmetic sequence.
S is the sum of all the elements in the arithmetic sequence.
Sn=n(a+an)=n(2a+d(n-1))
(2)
above. Your program should read the first term, the constant difference between consecutive elements, and the number of terms in the arithmetic sequence using the following command line: mpirun n <number of processes> ProgramName <a> <d> <number of terms> Your program should use block allocation of terms of the arithmetic sequence. Each processor should compute a local sum of the terms allocated to it. The processors should then perform a sum reduction. As a way of double-checking the result, processor 0 should also compute and print the value of the arithmetic series using equation (2). 2) Rewrite the same program using OpenMP, use cyclic allocation of terms of the arithmetic sequence.