I'm trying to calculate the value of e using the following Java code:
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int n;
System.out.print("number of values: ");
n = scnr.nextInt();
double e = 0.0;
double f = 1.0;
for (int i = 1; i <= n; i++) {
f = f * (i);
e += 1 / f;
}
e += 1;
System.out.print(e);
}
}
However, when I print out e, the number it limited to 2.7182818284590455 instead of a much more specific number (2.7182818284590455 x 10^-308 or something similar). Is it a problem with the Types I'm using?