I need to approximate e using the series: e= 1+ 1/1! +1/2!+..+1/n! which n=100000 this is what i did, but it refused to compile..
public class Test {
public static void main(String args[]) {
long e = 0;
for (int i = 1; i <= 100000; i++) {
e += 1.0 / factorial(i);
}
System.out.println(e);
}
public static long factorial(long number) {
if (number <= 1) return 1;
else return number * factorial(number - 1);
}
}