public class test3 {
public static void main(String[] args) {
int a=10,b=12,sum=0;
for (int i = 0; i < 100; i++) {
sum=sum+b; //sum为12+22+32+...+1002
b=b+a; //b的值为12,22,32。。。1002
}
System.out.println(sum);
public static void main(String[] args) {
int sum = 0;
int x = 12;
while(true){
if (x <= 1002) {
sum += x;
x += 10;
} else {
break;
}
}
System.out.println(sum);
}
}