代码实现:求100之内的素数

//求100之内的素数
public class Test {

	public static void main(String[] args) {
		int count = 0;	
		for (int i =2 ; i<100 ;i++ ){
			boolean flag=true ;
			 for(int j = 2 ; j < i;j++){
				if( i % j == 0 ){
					flag=false;
					break ;
				}
			}
			if(flag){
				System.out.print(i + "\t");
				count++;
				if(count % 5 == 0){
				System.out.println();
				}
			}	
		}
	}
}

 

posted on 2017-03-09 19:58  LoaderMan  阅读(449)  评论(0编辑  收藏  举报

导航