Skip to content

Commit 48af9cd

Browse files
authored
Java Primality Test
HackerRank Java Primality Test.
1 parent 3b8b8a7 commit 48af9cd

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Java Primality Test

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import java.io.*;
2+
import java.math.*;
3+
import java.security.*;
4+
import java.text.*;
5+
import java.util.*;
6+
import java.util.concurrent.*;
7+
import java.util.regex.*;
8+
9+
public class Solution {
10+
11+
12+
13+
private static final Scanner scanner = new Scanner(System.in);
14+
15+
public static void main(String[] args) {
16+
String n = scanner.nextLine();
17+
BigInteger bn=new BigInteger(n);
18+
if(bn.isProbablePrime(1))
19+
{
20+
System.out.println("prime");
21+
}
22+
else
23+
{
24+
System.out.println("not prime");
25+
}
26+
27+
scanner.close();
28+
}
29+
}

0 commit comments

Comments
 (0)