分别用do-while和for循环计算1+1/2!+1/3!+1/4!+...的前20项的和(做业)

public class sran{ public static void main(String args[]){ double a=1,b=1,c=0; System.out.println("do-while循环:"); do{ c=b+c; a++; b=(1.0/a)*b; } while(a<=20); System.out.println(" "+c); System.out.pri
相关文章
相关标签/搜索