Skip to content

Commit 45539c9

Browse files
Check number PrimePalindrome or not
1 parent 2abc997 commit 45539c9

2 files changed

Lines changed: 34 additions & 35 deletions

File tree

Number Theory/PalPrime.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

Number Theory/PrimePal.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import java.io.*;
2+
import java.util.*;
3+
public class PrimePal
4+
{
5+
public static void main(String args[])
6+
{
7+
Scanner in= new Scanner(System.in);
8+
int nm,pn,rev,s=0,i,c=0;
9+
System.out.println("Enter No.");
10+
nm= in.nextInt(); // User input
11+
pn=nm; // store the entered number in "pn" variable
12+
for(i=1;i<=pn;i++)
13+
{
14+
if(pn%i==0)
15+
{
16+
c++;
17+
}
18+
}
19+
while(nm>0)
20+
{
21+
rev=nm%10; // extract last digit of the number
22+
s=s*10+rev; // store the digit last digit
23+
nm=nm/10; // extract all digit except the last
24+
}
25+
if(pn==s&&c==2) // comparing with original number
26+
{
27+
System.out.println("Number is PalPrime : "+pn);
28+
}
29+
else
30+
{
31+
System.out.println("Number is not PalPrime : "+pn);
32+
}
33+
} // end of main method
34+
} // end of class

0 commit comments

Comments
 (0)