1 package jiecheng; 2 3 public class ted { 4 5 public static void main(String[] args) { 6 7 double tex = 0,a = 1; 8 int i = 1; 9 while(i <= 20) 10 { 11 tex = tex+a; 12 i = i+1; 13 a = a*(1.0/i); 14 } 15 System.out.println(tex); 16 17 } 18 19 } 用 while语句输出阶乘倒数的和
时间: 2024-10-22 12:22:26