In this HackerRank Java Primality Test problem, we have given a large integer use the Java biginteger class isProbablePrime method to determine and print whether it's prime or not prime.

HackerRank Java Primality Test problem solution

HackerRank Java Primality Test problem solution

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

     public static void main(String[] args) {
     Scanner in = new Scanner(System.in);
     BigInteger n = in.nextBigInteger();
     in.close();
      if(n.isProbablePrime(1)){
         System.out.println("prime");
      }
      else{
         System.out.println("not prime");
      }

    }
}