题解 | #素数回文#
素数回文
https://www.nowcoder.com/practice/d638855898fb4d22bc0ae9314fed956f
#include <stdio.h> #include<math.h> int main() { int a; while (scanf("%d", &a) != EOF) { //回文数 int ret = a; long sum = a; int i = 0; while(ret) { i++; if(i!=1) sum = sum*10 + ret % 10; ret /= 10; }//找到回文数 int flag = 0; double n = sqrt(sum); for(int j = 2;j < n;j++) { if(sum % j == 0) { flag = 1; break; } }//判断是否回文 if(flag == 0) { printf("prime\n"); }else { printf("noprime\n"); } } return 0; }