里面的i++是while 循环之后在加加有图最好
谢谢给位大佬
package zddHomework;
public class Testfor {
public static void main(String[] args) {
int sum = 0;//用来计算和的累加器
int count = 0;//用来计数的累加器
for(int i = 2 ; i <=100 ; i ++){//用来进行循环1-100之间的
int j = 2;
while(i % j != 0){
j ++;
}
if(i == j){
System.out.println(i);
sum += j;
count ++;
}
}
System.out.println(sum + " " + count);
}
}
谢谢给位大佬
package zddHomework;
public class Testfor {
public static void main(String[] args) {
int sum = 0;//用来计算和的累加器
int count = 0;//用来计数的累加器
for(int i = 2 ; i <=100 ; i ++){//用来进行循环1-100之间的
int j = 2;
while(i % j != 0){
j ++;
}
if(i == j){
System.out.println(i);
sum += j;
count ++;
}
}
System.out.println(sum + " " + count);
}
}
