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