Java 一万以内素数

import java.util.Scanner;
public class Test {
    
    
    public static void main(String[] args) {
    
    
        int count =0;
        for(int i=2;i<10000;i++){
    
    
            boolean a=true;
            for(int j=2;j<=i;j++){
    
    
                if((i%j==0)&&(i!=j)){
    
    
                    a=false;
                    break;
                }
            }
            if(a){
    
    
                System.out.print(i+" ");
                count++;
            }
            if(count==10){
    
    
                System.out.println();
                count=0;
            }
        }
    }
}


猜你喜欢

转载自blog.csdn.net/qq_45858803/article/details/121213159
今日推荐