1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| import java.math.*;
public class Main { public static double CalE(int x) { double ans = 1, s = x; for (int i = 2; s > 1e-8; i++) { ans += s; s = s * x * 1.0 / i; } return ans; }
public static void main(String[] args) { System.out.printf("%.8f", CalE(1)); } }
|