forked from ghostmkg/programming-language
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPal_Prime.java
More file actions
Latest commit
44 lines (44 loc) · 866 Bytes
/
Copy pathPal_Prime.java
File metadata and controls
44 lines (44 loc) · 866 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
42
43
44
importjava.util.*;
classPal_Prime
{
intpalin(intn)
{
ints=0,c;
while(n>0)
{
c=n%10;
s=s*10+c;
n=n/10;
}
returns;
}
intprime(intn)
{
inti,c=0;
for(i=1;i<=n;i++)
{
if(n%i==0)
c++;
}
returnc;
}
voidcheck(intl,intu)
{
inti;
for(i=l;i<=u;i++)
{
if(i==palin(i) && prime(i)==2)
System.out.println(i);
}
}
publicstaticvoidmain()
{
Scannersc=newScanner(System.in);
Pal_Primeob=newPal_Prime();
inta,b;
System.out.println("Enter lower and upper range");
a=sc.nextInt();
b=sc.nextInt();
ob.check(a,b);
}
}