I am trying to make a program in which a number is taken as input and the program displays the smallest number bigger than the input which is both prime and palindrome. But this program does not give any output. Can you please give me the reason? I am very new to programming, and it would be great if you could explain me the reason:
The program is as follows:
#include <stdio.h>
#include <math.h>
int checkp(long long int a);
int main() {
long long int n, i;
scanf("%lld", &n);
for (i = (n + 1);; i++) {
long long int reverse = 0, rem, temp;
int check;
temp = n;
while (temp != 0) {
rem = temp % 10;
reverse = reverse * 10 + rem;
temp /= 10;
}
if (reverse == i) {
check = checkp(i);
if (check == 1) {
return 0;
}
}
}
}
int checkp(long long int a) {
long long int b, i;
b = sqrt(a);
int flag = 0;
for (i = 2; i <= b; i++) {
if (a % i == 0) {
flag = 1;
break;
}
}
if (flag == 0) {
printf("%lld", a);
return 1;
} else
return 0;
}