/* Compute the value of e using the formula 1 + 1 / 1! + 1 / 2! + 1 / 3! + 1 / 4! + ... + 1 / i! for some i > 1. * As the values for both i! and 1 / i! may exceed available precision for long/double respectively, we use * BigInteger and BigDecimal */ import java.math.*; // for BigInteger and BigDecimal public class Prog10_20 { public static void main(String[] args) { BigDecimal e = new BigDecimal("0.0"); // our variable to store e as we compute it BigDecimal one = new BigDecimal("1.0"); // we need to do 1 / i!, so 1 needs to be stored in a BigDecimal for the divide operation BigInteger temp; // used to store the BigInteger value of i! that we get back from getFactorial int x = 20; // we are hardcoding the number of iterations here rather than inputting them for(int i=0;i