zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    GCD
    SQLite
    将博客搬至CSDN
    Extjs 4 总结
    spring mvc 复杂参数注入
    7/12 聊天室结束
    7/10
    7/6一些知识点
    随便写写
    spring boot 入门操作(三)
  • 原文地址:https://www.cnblogs.com/PoeticalJustice/p/7608788.html
Copyright © 2011-2022 走看看