package cn.edu.bjut.chapter2; public class PrimeNumber { public static void main(String[] args) { int n = 0, m, j, i; System.out.print("2"); label: for (i = 3; i <= 100; i += 2) { m = (int) Math.sqrt((double) i); for (j = 2; j <= m; j++) { if ((i % j) == 0) { break; } if (i == 51) { break label; } } if (j >= m + 1) { if (n % 6 == 0) { System.out.println("\n"); } System.out.print(i + " "); n++; } } } }