Mega Code Archive

 
Categories / Java / Data Type
 

BigInteger isProbablePrime

import java.math.BigInteger; public class BigNumApp {   public static void main(String args[]) {     BigInteger n = new BigInteger("1000000000000");     BigInteger one = new BigInteger("1");     while (!n.isProbablePrime(7))       n = n.add(one);     System.out.println(n.toString(10) + " is probably prime.");     System.out.println("It is " + n.bitLength() + " bits in length.");   } }