Package java.math

Examples of java.math.BigInteger.subtract()


                BigInteger.valueOf(nn));
            nn--;
            if (c.compareTo(i) <= 0)
            {
                result.setBit(j);
                i = i.subtract(c);
                tt--;
                if (nn == tt)
                {
                    c = ONE;
                }
View Full Code Here


        BigInteger n = new BigInteger(in.nextToken());
        BigInteger r = n.divide(TWO);
        if (n.remainder(TWO).equals(BigInteger.ONE)) {
            out.println(r);
        } else {
            r = r.subtract(BigInteger.ONE);
            if (r.remainder(TWO).equals(BigInteger.ZERO)) {
                r = r.subtract(BigInteger.ONE);
            }
            out.println(r);
        }
View Full Code Here

        if (n.remainder(TWO).equals(BigInteger.ONE)) {
            out.println(r);
        } else {
            r = r.subtract(BigInteger.ONE);
            if (r.remainder(TWO).equals(BigInteger.ZERO)) {
                r = r.subtract(BigInteger.ONE);
            }
            out.println(r);
        }
        out.flush();
    }
View Full Code Here

        }
        Matrix init = new Matrix(false);
        for (int i = 0; i < (1 << m); ++ i) {
            init.set(0, i, 1);
        }
        init = init.multiply(transform.pow(n.subtract(BigInteger.ONE)));
        int result = 0;
        for (int i = 0; i < (1 << m); ++ i) {
            result = (result + init.get(0, i)) % p;
        }
        out.println(result);
View Full Code Here

        while (r.equals(ECConstants.ZERO));

        // generate s
        BigInteger x = privKey.getD();                // private key value
        BigInteger u = ((ECPrivateKeyParameters)tempPair.getPrivate()).getD();    // temp's private key value
        s = u.subtract(r.multiply(x)).mod(n);

        BigInteger[]  res = new BigInteger[2];
        res[0] = r;
        res[1] = s;
View Full Code Here

            {
                // mu == -1
                s = u1.negate();
            }
           
            u2 = s.subtract(u0.shiftLeft(1));
            u0 = u1;
            u1 = u2;
//            System.out.println(i + ": " + u2);
//            System.out.println();
        }
View Full Code Here

               
                byte uLocal;
                // if uUnMod >= 2^(width - 1)
                if (uUnMod.compareTo(pow2wMin1) >= 0)
                {
                    uLocal = (byte) uUnMod.subtract(pow2w).intValue();
                }
                else
                {
                    uLocal = (byte) uUnMod.intValue();
                }
View Full Code Here

                BigInteger  x = new BigInteger(1, w);

                BigInteger  c = x.mod(q.multiply(TWO));

                p = x.subtract(c.subtract(ONE));

                if (p.testBit(size - 1))
                {
                    if (p.isProbablePrime(certainty))
                    {
View Full Code Here

            // mQ = ((input mod q) ^ dQ)) mod q
            mQ = (input.remainder(q)).modPow(dQ, q);

            // h = qInv * (mP - mQ) mod p
            h = mP.subtract(mQ);
            h = h.multiply(qInv);
            h = h.mod(p);               // mod (in Java) returns the positive residual

            // m = h * q + mQ
            m = h.multiply(q);
View Full Code Here

            if (!p.isProbablePrime(param.getCertainty()))
            {
                continue;
            }
           
            if (e.gcd(p.subtract(ONE)).equals(ONE))
            {
                break;
            }
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.