public class Total{ public static void main(String[] args){
int total = 0;
for(int num = 2; num <= 100;num = num*2){
total += num;
}
System.out.println("100以内的偶数和为:"+total);
}
}
public class Total{ public static void main(String[] args){
int total = 0;
for(int num = 2; num <= 100;num = num*2){
total += num;
}
System.out.println("100以内的偶数和为:"+total);
}
}
转载于:https://my.oschina.net/u/1388978/blog/176243