-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmega_prime.java
More file actions
48 lines (46 loc) · 1003 Bytes
/
mega_prime.java
File metadata and controls
48 lines (46 loc) · 1003 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
45
46
47
48
import java.util.Scanner;
class vamsi
{
static boolean is_prime(int n){
int c=0,i=1;
while(i<=n)
{
if(n%i==0){
c+=1;
}
i+=1;
}
if(c==2){
return true;
}
else{
return false;
}
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int rev=0,c1=0,c2=0,temp=n,d,i;
if(is_prime(n)){
temp=n;
while(n!=0){
d=n%10;
c1+=1;
if(is_prime(d)){
c2+=1;
}
n/=10;
}
if(c1==c2){
System.out.println("Mega Prime");
}
else{
System.out.println("Not Mega Prime");
}
}
else{
System.out.println("Not Mega Prime");
}
}
}