if (++j == k) { return false; } y = y.modPow(TWO, n);
    public boolean isProbablePrime(int certainty)    {        if (certainty == 0)        {            return true;        }        BigInteger n = this.abs();        if (n.equals(TWO))        {            return true;        }        if (n.equals(ONE) || !n.testBit(0))        {            return false;        }        if ((certainty & 0x1) == 1)        {            certainty = certainty / 2 + 1;        }        else        {            certainty /= 2;        }        //        // let n = 1 + 2^kq        //        BigInteger q = n.subtract(ONE);        int k = q.getLowestSetBit();        q = q.shiftRight(k);        Random rnd = new Random();        for (int i = 0; i <= certainty; i++)        {            BigInteger x;            do            {                x = new BigInteger(n.bitLength(), rnd);            } while (x.compareTo(ONE) <= 0 || x.compareTo(n) >= 0);            int j = 0;            BigInteger y = x.modPow(q, n);            while (!((j == 0 && y.equals(ONE)) || y.equals(n.subtract(ONE))))            {                if (j > 0 && y.equals(ONE))                {                    return false;                }                if (++j == k)                {                    return false;                }                y = y.modPow(TWO, n);            }        }        return true;    }