public class Ninetheen { /*求1+2!+3!+...+20!的和*/ public static void main(String[] args){ int i,j; long sum=0,jiecheng=1; for(i=1;i<=20;i++){ jiecheng=1; for(j=1;j<=i;j++) jiecheng=jiecheng*j; sum=sum+jiecheng; } System.out.println("1+2!+3!+...+20!的和是:"+sum); } }