1 package zuoye; 2 3 public class zuoyetest 4 { 5 6 public static void main(String[] args) 7 { 8 int c=20; 9 double d=1; 10 double sum=0; 11 double e=1; 12 13 while (true) 14 { 15 if (d<=c) 16 { 17 e=e*d; 18 e=1/e; 19 d++; 20 sum=sum+e; 21 continue; 22 23 } 24 System.out.println("阶乘的和="+sum); 25 if (d>c) 26 { 27 break; 28 } 29 } 30 } 31 32 }