package hello; public class jiecheng { public static void main(String[] args) { /*int n=4; long l=1; for(int i=1;i<=n;i++) { l=l*i; //阶乘结果 } System.out.print(l);*/ int n=20; double d=0; for(int k=1;k<=n;k++) { long s=1; for(int i=1;i<=k;i++){ s=s*i; } d=d+(1/(double)s); } System.out.println(d); } }