while and for 2

Posted PoeticalJustice

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)+"\t");
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 }

 

以上是关于while and for 2的主要内容,如果未能解决你的问题,请参考以下文章

cpp test for and while loop time cost respectively while std::chrono::high_resolution_clock

Execution failed for task ‘:app:processDebugResources‘. > A failure occurred while executing com.and

Errors were encountered while preparing your device for development. Please check the Devices and Si

Errors were encountered while preparing your device for development. Please check the Devices and Si

Errors were encountered while preparing your device for development. Please check the Devices and Si

Nginx——Nginx启动报错Job for nginx.service failed because the control process exited with error code(代码片段