其他分享
首页 > 其他分享> > 随堂练习

随堂练习

作者:互联网

package ox;

/**
* 1!+2!+...+10!
*
* 1+2+3+....n >8888 求n
*/
public class demo02 {
public static void main(String[] args) {
show1();
}
//1+2+3+....n >8888 求n
private static void show2() {
int n =1,sum=0;
for (int i = 1; i <= 10; i++) {
n=n*i;
sum=n+sum;
//System.out.println(i);
}
System.out.println(sum);
}

//1!+2!+...+10!
private static void show1() {
int n=0;
for (int i = 1; i < 8888; i++) {
n=n+i;
if (n>8888){
System.out.println(i);
break;
}
}

}
}

标签:8888,int,sum,练习,随堂,System,static,out
来源: https://www.cnblogs.com/ndog/p/16348472.html