1 public class Solution 2 { 3 public static void main(String[] args) 4 { 5 int totalCount = 0; 6 int lineCount = 0; 7 int i = 2; 8 9 while(true)10 {11 if(isPrime(i) && isPalindrome(i))12 {13 System.out.print(i + " ");14 totalCount++;15 lineCount++;16 }17 18 i++;19 20 if(lineCount == 10)21 {22 System.out.println();23 lineCount = 0;24 }25 26 if(totalCount == 100)27 break;28 }29 }30 31 public static boolean isPrime(int number)32 {33 if(number == 1)34 return false;35 else if(number == 2)36 return true;37 else38 {39 for(int i = 2; i < number; i++)40 {41 if(number % i == 0)42 return false;43 }44 return true;45 }46 }47 48 public static int reverse(int number)49 {50 String strOfNumber = "";51 if(number < 10)52 strOfNumber += number + "";53 else54 strOfNumber += "" + number % 10 + reverse(number / 10);55 return Integer.parseInt(strOfNumber);56 }57 58 public static boolean isPalindrome(int number)59 {60 int backupNumber = reverse(number);61 if(number == backupNumber)62 return true;63 else64 return false;65 }66 }