素数:即除1和本身以外,不能被其他数整除
1 public class java_7 { 2 public static void main(String[] args) { 3 // TODO Auto-generated method stub 4 // 用于统计个数 5 int count = 0; 6 7 for(int n = 2;n <= 200;n++){ 8 // 用于记录是否为素数 9 boolean isPrime=true; 10 11 for(int i = 2; i < n; i++) { 12 if(n % i == 0) { 13 isPrime = false; 14 break; 15 } 16 } 17 if(isPrime) { 18 System.out.print(n + "\t"); 19 count++; 20 if(count % 10 == 0){ 21 System.out.println(); 22 } 23 } 24 } 25 26 } 27 }
原文:http://www.cnblogs.com/jiejie95/p/4963807.html