JAVA编程--------21、求1!+2!+....+20!=

 1 package FushiExam;
 2 
 3 public class Text_21 {
 4 
 5     public static void main(String[] args) {
 6         // 求1!+2!+3!+....+20!=
 7          double sum=0,t;//用double定义,是因为int在13!时,因为位数不够而出错
 8         for(int i=1;i<=20;i++) {
 9             t=1;
10             for(int j=1;j<=i;j++) {
11                 t=t*j;
12             }
13             System.out.println(i+"!="+t);
14             sum=sum+t;
15         }
16         System.out.println("1!+2!+3!+...+20!="+sum);
17     }
18 
19 }
原文地址:https://www.cnblogs.com/fmust/p/12491649.html