forked from mba-mba/HacktoberFest2020-1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPal.java
More file actions
41 lines (41 loc) · 870 Bytes
/
Pal.java
File metadata and controls
41 lines (41 loc) · 870 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
32
33
34
35
36
37
38
39
40
41
import java.util.*;
class Palprime
{
public int Pal(int n)
{
int d=0;int s=0;
for(int i=n;i>0;i=i/10)
{
{
d=i%10;
s=s*10+d;
}
}
return(s);
}
public int prime(int n)
{
int c=0;
for(int i=1;i<=n;i++)
{
if(n%i==0)
{
c++;
}
}
return(c);
}
public static void main()
{
Scanner in=new Scanner(System.in);
System.out.println("Enter the no");
int n=in.nextInt();
Palprime obj=new Palprime();
int s1=obj.Pal(n);
int c1=obj.prime(n);
if((s1==n)&&(c1==2))
System.out.println("Palprime no"+n);
else
System.out.println("Not a palprime no"+n);
}
}