Java第三章习题3-7(1到n的阶乘和 /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author Administrator */ public class Find { public void main{ int n=9999; int sum=0; int k=1,i=1; for( i=1;i<=10;i++){ k=k*i; sum=sum+k; if(sum>9999){ break; } } (i-1);

时间:2025-02-10 12:02:51

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Administrator
 */
public class Find {
    public void main(){
        int n=9999;
        int sum=0;
        int k=1,i=1;
        for( i=1;i<=10;i++){
            k=k*i;
            sum=sum+k;
            if(sum>9999){
                break;
            }
        }
        (i-1);

            
    }
    
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Administrator
 */
public class Test {
    public static void main(String[] args){
        Find f=new Find();
        ();
    }
    
}