public class test {
public static void main(String[] args) {
int count=0;
for(int i=1,j=2;count<50;i++,j++){
if(isPrime(j)&&isPalindrome(j)){
count++;
if(count%10==0)
System.out.println(j);
else
System.out.print(j+" ");
}
}
}
public static boolean isPrime(int number){
for(int i=2;i<number;i++){
if(number%i==0)
return false;
}
return true;
}
public static boolean isPalindrome(int number){
String str=""+number;
for(int i=0,j=str.length()-1;i<str.length()/2;i++,j--){
if(str.charAt(i)!=str.charAt(j))
return false;
}
return true;
}
}