-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe.java
55 lines (34 loc) · 929 Bytes
/
e.java
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
52
53
54
55
import java.util.Scanner;
public class e{
public static void main(String[]args) {
double E;
double number;
int factorial;
int counter1;
int counter2;
int counter3;
counter1=0;
E=1;
counter2=1;
factorial=1;
number=1;
counter3=1;
Scanner input=new Scanner(System.in);
System.out.println("Enter how many digits you want");
number=input.nextInt();
while(counter1<=number) {
counter1++;
counter2=1;
factorial=1;
while (counter2<=counter1) {
factorial=factorial*counter2; ////ohhhhhhh u must reset the factorial variable so that the multiplcation doesnt go endlessly
counter2++;
//if (fact)
//ok so the overall algorithm is correct but there are just some things that a bit off lol
}
E+=Math.pow(factorial, -1);
System.out.println(E);
}
//System.out.printf("this is the value of %.1f",E);
}
}