2016/1/6 输出菱形 while语句计算阶乘分数之和

 1 public class LingXing {
 2 
 3 
 4     public static void main(String[] args) {
 5         //打印菱形
 6         for (int x=1;x<6;x++){
 7             for(int p=x;p<5;p++){
 8                 System.out.print(" ");
 9             }
10             for(int y=0;y<x;y++){
11                 System.out.print("* ");
12             }
13             
14             System.out.println();
15         }
16         for (int m=5;m>0;m--){
17             for(int p=m;p<=5;p++){
18                 System.out.print(" ");
19             }
20             for (int n=1;n<m;n++){
21                 System.out.print("* ");    
22             }
23             System.out.println();
24             }

 1 double t=1;
 2         double sum=0;
 3         double d=1;
 4         
 5         while (t<=20){
 6             
 7         d*=t;
 8         sum+=1/d;
 9         t++;
10             System.out.println(1/d);
11         }
12             System.out.println("1+1/2!+...+1/20!="+sum);
13         }
14         
15     }

原文地址:https://www.cnblogs.com/haodayikeshu/p/5105125.html