program the computation of the euler constant using a loop for a given value of n using the following instructions

a.

Create a package named

cs520.hw1.part2

b.

Create a class named

EulerConstant

under the above package with the main method.

c.

Write the static method

,compute, that takes the number n as its argument. The code for this method should use a loop to calculate the result using the formula shown in

the above equation. The method returns the computed result.

Reuse the factorial computed in the previous iteration for the next iteration, i.e., do not explicitly compute each factorial in each iteration of the loop. In each iteration, print the intermediate results as shown in the sample output.

d.

The code in the main method should do the following:

i. Invoke the method, compute, for n = 2, and store the result into the variable, result1.

ii. Print the result to the console.

iii.Invoke the method, compute, for n = 5, and store the result into the variable, result2.

iv.

Print the result to the console.

v.

Invoke the method, compute, for n = 12, and store the result into the variable, result3.

vi.

Print the result to the console.

vii.

Print the difference between result2 and result1, and result3 and result2. The double values are printed to 9 decimal places using the printf’s%.9f format