Please shpw the code in java and the algorithm(pseudocode) Assignment: Write an
ID: 3743138 • Letter: P
Question
Please shpw the code in java and the algorithm(pseudocode)
Assignment: Write an algorithm (pseudocode) and program to compute e. The calculation of the important mathematical constant e will be done as the sum of an infinite series: e = 1/n! n=0
Output: Output will include your computed value for e, the math library constant “expected value” for e and the number of iterations (loop executions) it took to reach sixteen-decimal-place accuracy (2.7182818284590450). Make your output clean, labeled, and easy to read for comparing results. No computational rounding is allowed. Acceptable output would look something like: Computed value of e : 2.7182818284590450 Expected value of e : 2.7182818284590450 Required iterations : 30
Note: # of iterations above is not correct.
Input: No user input.
Explanation / Answer
///////////////////////////////////////////////////
// Algorithm to find out value of e
Step 0: Start
Step 1 : Intialise sum = 0, Declare variable sum, value, i and k;
Step 2: Assign i =0;
Step 3: check condition i is less than VERYLARGEVALUE
Step 4 : If condition hold true go to 6
Step 5 : Else go to step 18
Step 6: Assign Value = 1
Step 7: Assign k =0;
Step 8: check condition k is less than i
Step 9 : If condition hold true go to step 11
Step 10 : Else go to step 14
Step 11 Assign Value = Value * k
Step 12: increment k by 1
Step 13: Go to step 8
Step 14 : Calculate Value = 1/Value;
Step 15: Calculate Sum = Sum + Value;
Step 16: Increment i by 1
Step 17: Go To Step 3
Step 18: Print sum i.e.(value of e)
Step 19: End