Java Primality Test

  • + 0 comments
    import java.io.*;
    import java.math.*;
    class Solution{
        public static void main(String[]args) throws IOException{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String n=br.readLine();
            br.close();
            BigInteger bi=new BigInteger(n);
            if(bi.isProbablePrime(10)){
                System.out.println("prime");
            }else{
                    System.out.println("not prime");
                }
            }
        }