A prime palindrome number is a number which is prime and palindrome both.

1 2 3 4 |
<h2>Output</h2> Enter a number: 131 The number is a Prime Palindrome number. |

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
import java.io.*; class palprime { boolean isprime(int n) { int i; for(i=2;i<=n/2;i++) { if(n%i==0) return false; } return true; } boolean ispalin(int n) { int n2=n, d, r=0; while(n!=0) { d=n%10; n=n/10; r=r*10+d; } if(r==n2) return true; return false; } public static void main()throws IOException { BufferedReader r= new BufferedReader(new InputStreamReader(System.in)); int m; palprime ob = new palprime(); System.out.println("Enter a number:"); m = Integer.parseInt(r.readLine()); if(ob.isprime(m)&&ob.ispalin(m)) System.out.println("The number is a Prime Palindrome number."); else System.out.println("The number is not a Prime Palindrome number."); } } |

## Leave a Reply