Java tutorial
import java.math.BigInteger; import java.util.Random; public class Main { public static void main(String[] args) { int bitLength = 3; // create a random object Random rnd = new Random(); BigInteger bi = BigInteger.probablePrime(bitLength, rnd); System.out.println(bi); } }