1、九九乘法表
int sum=0;
for(int i=1;i<=9;i++) {
for (int j = 1; i >= j; j++) {
sum = i * j;
System.out.print(j + "*" + i + "=" + sum + "\t");
}
System.out.println();
2、求算 1到10的阶乘和
int sum2=0;
for(int i=1;i<=10;i++){
int sum1=1;
for(int j=1;j<=i;j++){
sum1=sum1*j;
}
sum2+=sum1;
}
System.out.println("sum2="+sum2);
System.out.println("#############");
int x=1;
int sum4=0;
while(x<=10){
int sum3=1;
for (int y=1;y<=x;y++){
sum3*=y;
}
x++;
sum4+=sum3;
}
System.out.println("sum4="+sum4);
System.out.println("#############");
int m=1;
int sum6=0;
do{
int sum5=1;
for (int n=1;n<=m;n++){
sum5*=n;
}
m++;
sum6+=sum5;
} while(m<=10);
System.out.println("sum6="+sum6);
3、求累加1的和一直到累加100的和
int sum2=0;
for(int i=1;i<=100;i++){
int sum1=0;
for(int j=1;j<=i;j++){
sum1+=j;
}
sum2+=sum1;
}
System.out.println(sum2);