-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrime_Palindrome.java
More file actions
31 lines (31 loc) · 824 Bytes
/
Prime_Palindrome.java
File metadata and controls
31 lines (31 loc) · 824 Bytes
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
import java.util.*;
class Prime_Palindrome{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("Enter any number");
int n=sc.nextInt();
boolean prime=true;
for(int x=2;x<n;x++){
if(n%x==0){
prime=false;
break;
}
}
if(prime){
int r=0;
for(int x=n;x!=0;x/=10){
int d=x%10;
r=r*10+d;
}
if(r==n){
System.out.println(n+" is a Prime Palindrome Number");
}
else{
System.out.println(n+" is not a Prime Palindrome Number");
}
}
else{
System.out.println(n+" is not a Prime Number");
}
}
}