-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise05_26.java
More file actions
51 lines (44 loc) · 1.3 KB
/
Copy pathExercise05_26.java
File metadata and controls
51 lines (44 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package Chapter5;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author jorda
*/
public class Exercise05_26 {
public static void main(String[] args){
double dE = 0.0;
double value = 10000.0;
for (int i = 1; i < value; i++) {
double denominator = i;
for (int j = i; j >=1; j--) {
denominator *= j;
}
dE += 1 / denominator;
}
System.out.println("The e value for i = 10000: " + dE);
dE = 0.0;
value = 20000.0;
for (int i = 1; i < value; i++) {
double denominator = i;
for (int j = i; j >=1; j--) {
denominator *= j;
}
dE += 1 / denominator;
}
System.out.println("The e value for i = 20000: " + dE);
dE = 0.0;
value = 100000.0;
for (int i = 1; i < value; i++) {
double denominator = i;
for (int j = i; j >=1; j--) {
denominator *= j;
}
dE += 1 / denominator;
}
System.out.println("The e value for i = 100000: " + dE);
}
}