package pritice4;
public class PalindromicPrime {
public static int IsOrNotPrime(int a)//判断是不是素数
{
int i,status = 1;
for(i=2;i<=a/2;i++)
{
if(a%i == 0) {status = 0;break;}
else status = 1;
}
return status;
}
public static int IsOrNotPalindromic(int i)
{
int p = i,sum = 0;
while(p!=0)
{
sum = sum*10 + p%10;
p /= 10;
}
if(sum == i) return 1;
return 0;
}
public static void main(String[] args) {
//输出回文素数
final int N = 100;//打印100个
final int LINE = 10;//10个进行换行
int i,count = 0;
for(i=2;count<100;i++)
{
int a =IsOrNotPrime(i);
int b = IsOrNotPalindromic(i);
if(a!=0 && b!=0) {
count++;
if(count%LINE == 0)
{
System.out.printf("%6d",i);
System.out.println();
}
else
System.out.printf("%6d",i);
}
}
}
}
public class PalindromicPrime {
public static int IsOrNotPrime(int a)//判断是不是素数
{
int i,status = 1;
for(i=2;i<=a/2;i++)
{
if(a%i == 0) {status = 0;break;}
else status = 1;
}
return status;
}
public static int IsOrNotPalindromic(int i)
{
int p = i,sum = 0;
while(p!=0)
{
sum = sum*10 + p%10;
p /= 10;
}
if(sum == i) return 1;
return 0;
}
public static void main(String[] args) {
//输出回文素数
final int N = 100;//打印100个
final int LINE = 10;//10个进行换行
int i,count = 0;
for(i=2;count<100;i++)
{
int a =IsOrNotPrime(i);
int b = IsOrNotPalindromic(i);
if(a!=0 && b!=0) {
count++;
if(count%LINE == 0)
{
System.out.printf("%6d",i);
System.out.println();
}
else
System.out.printf("%6d",i);
}
}
}
}