You are viewing a single comment's thread. Return to all comments →
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger;
public class PrimalityTest {
public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String n = reader.readLine(); try { BigInteger bint = new BigInteger(n); //With certainty level set to 100 System.out.println(bint.isProbablePrime(100)?"prime":"not prime"); }catch (NumberFormatException e) { System.err.println("Please enter the integer digits only: "+e.getMessage()); } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Java Primality Test
You are viewing a single comment's thread. Return to all comments →
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger;
public class PrimalityTest {
}