public static void main() { int sum = 0, num = 0; for(int i = 1; i <= 5000; ++i) { if(i%30 == 0) //能被3整除且能被十整除即能被30整除 { sum+=i; num++; } } system.out.println(sum); //总和 system.out.println(sum*1.0/num); //平均值}