gistfile1.txt public class Test2{public static void main(String[] args){double sum = 1;double x = 1;for(int i=1;i=100;i++){sum += 1.0/x;x = x*(i+1);}System.out.println("1 + 1/1! + 1/2! + 1/3! + … + 1/100!="+sum);}}
public class Test2 { public static void main(String[] args) { double sum = 1; double x = 1; for(int i=1;i<=100;i++) { sum += 1.0/x; x = x*(i+1); } System.out.println("1 + 1/1! + 1/2! + 1/3! + … + 1/100!="+sum); } }