源码:
package com.hp.demo;
public class Test2 {
public static void main(String[] args) {
for (int i =1; i <100; i++) {
boolean re=true;
for (int j =2; j <=i-1; j++) {
if (i%j==0) {
re=false;
}
}
if (re==true) {
System.out.println("素数为"+i);
}
}
}
}
运行效果:



