-
Notifications
You must be signed in to change notification settings - Fork 6
/
10235.java
31 lines (28 loc) · 844 Bytes
/
10235.java
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
//Steven Kester Yuwono - UVa 10235
import java.util.Scanner;
import java.math.BigInteger;
class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
int a = cin.nextInt();
BigInteger first = BigInteger.valueOf(a);
String temp = first.toString();
StringBuffer tempBuffer = new StringBuffer(temp);
tempBuffer = tempBuffer.reverse();
temp = tempBuffer.toString();
int b = Integer.parseInt(temp);
BigInteger second = new BigInteger(temp);
System.out.printf("%d is ",a);
if(!first.isProbablePrime(10)){
System.out.println("not prime.");
}
else if((a!=b)&&(second.isProbablePrime(10))){
System.out.println("emirp.");
}
else{
System.out.println("prime.");
}
}
}
}