【JAVA习题二十二】求100之内的素数

package erase;
public class 一百以内的素数判断 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        for(int i=2;i<=100;i++) {
            Sushu(i);
        }
    }
    public static void Sushu(int n) {
        boolean flag=true;
        for(int i=2;i<=n/2;i++) {
            if(n%i==0)
                flag=false;
        }
        if(flag) {
            System.out.print(n+" ");
        }
    }

}
原文地址:https://www.cnblogs.com/chenxi1944362410/p/13050155.html