HackerRank Java- Primality Test
Given a large integer, n, use the Java BigInteger class' isProbablePrime method to determine and print whether it's prime or not prime.
- import java.io.*;
- import java.math.*;
- import java.security.*;
- import java.text.*;
- import java.util.*;
- import java.util.concurrent.*;
- import java.util.regex.*;
-
- public class Solution {
-
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- BigInteger n = sc.nextBigInteger();
- sc.close();
- System.out.println(n.isProbablePrime(10) ? "prime" : "not prime");
- }
- }