1 public class Solution 2 { 3 public static void main(String[] args) 4 { 5 int[] prime = new int[50]; 6 prime[0] = 2; 7 int i = 0; 8 int j = 3; 9 boolean judgment = false;10 while(true)11 {12 i = 0;13 while(i < 50 && prime[i] != 0)14 {15 if(j % prime[i] == 0)16 {17 judgment = false;18 break;19 }20 i++;21 }22 23 for(int k = 0; k < 50; k++)24 {25 if(judgment == true && prime[k] == 0)26 {27 prime[k] = j;28 break;29 }30 }31 32 judgment = true;33 j++;34 35 if(prime[prime.length - 1] != 0)36 break;37 }38 39 40 int count = 0;41 for(int k = 0; k < 50; k++)42 {43 System.out.print(prime[k] + " ");44 count++;45 if(count == 10)46 {47 System.out.println();48 count = 0;49 }50 }51 52 }53 }