class For1
{
public static void main(String[] args)
{
int count = 0;
for (int x = 2;x<10 ;x++ )
{
int num = 0;
for (int y = 2;y<=x/2 ;y++ ) //可以去一半值范围,超出一般可以排除
{
if (x%y==0)
{
++num;
}
}
if (num==0)
{
++count;
System.out.println(x+" ");
}
//System.out.println();
}
System.out.println("count="+count);
}
} |
|