while and for 2

 1 public class TestWhileAndFor2 {
 2 
 3     /**
 4      * 九九乘法表
 5      * 1!+2!+3!+....+10!=?
 6      *  
 7      */
 8     public static void main(String[] args) {
 9         /*
10         for(int i=1;i<=9;i++){
11             for(int j=1;j<=i;j++){
12                 System.out.print(j+"*"+i+"="+(j*i)+"	");
13                 }
14             System.out.println();
15         }
16         */
17         //1!+2!+3!+....+10!=?
18         long sum=1;
19         long total=0;
20         for(int j=1;j<=10;j++){
21             sum=sum*j;
22             total+=sum;
23             System.out.println(j+"!="+sum);
24         }
25         
26         System.out.println(" 1!+2!+3!+....+10!="+total);
27         
28         //1+2+3..+10=?
29         long count=0;
30         for(int i=1;i<=10;i++){
31             count+=i;
32         }
33         System.out.println(count);
34     }
35     
36 
37 }
原文地址:https://www.cnblogs.com/PoeticalJustice/p/7608788.html