public class jiecheng2 { public static void main(String[] args) { // 1+1/2!+1/3!+1/4!=1/5!+...+1/20!=? int x=20; double a =1; for(int z=1;z<=x;z++){ long y=1; for(int i=1;i<=z;i++){ y=y*i; } a=a+(double)(1/(double)y); } System.out.println(a); } }
时间: 2024-10-11 18:18:20