程序设计
找出100-900 之间的无暇素数。所谓无暇素数是指本身为素数,且其逆序数也是素数的数。例如:113是一个素数,311也是一个素数,113就是无暇素数。
运行代码:
#include <stdio.h>
int main( )
{
int i,j,n,x,ge,shi,bai;
for(i=100; i<900; i++)
{
for(j=2; j<i; j++)
{
if(i%j==0 && i!=j)
{
break;
}
}
if(i==j)
{
ge=i/1%10;
shi=i/10%10;
bai=i/100%10;
n=ge*100+shi*10+bai;
for(x=2; x<n; x++)
{
if(n%x==0 && n!=x)
{
break;
}
}
if(n==x)
{
printf("%d\n",i);
}
}
}
}