打印出1000之内的所有质数。
package com;
public class Sushu {
public static void main(String[] args) {
// TODO Auto-generated method stub
int i,j,count = 0;
int flag = 0;
for(i=2;i<=1000;i++)
{
for(j=2;j<i;j++)
if(i%j==0)
flag = 1;
if(flag==0)
{
System.out.print(i + "\t" );
count++;
if(count%20 == 0)
System.out.printf("\n");
}
flag = 0;
}
}
}