阅读背景:

Java第三章习题3-7(1到n的阶乘和<=9999)

来源:互联网 

Find.java

/*
 * 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;
            }
        }
        System.out.println(i-1);

            
    }
    
}
/*
 * To change this template, choo



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: