Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication6;
- import java.math.BigInteger;
- /**
- *
- * @author student
- */
- public class JavaApplication6 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- BigInteger n1 = new BigInteger("837210799");
- BigInteger e1 = new BigInteger("7");
- BigInteger d1 = new BigInteger("478341751");
- BigInteger n2 = new BigInteger("837210799");
- BigInteger e2 = new BigInteger("17");
- BigInteger d2;
- BigInteger k;
- BigInteger zero = new BigInteger("0");
- BigInteger one = new BigInteger("1");
- BigInteger two = new BigInteger("2");
- BigInteger four = new BigInteger("4");
- BigInteger pplusq;
- BigInteger deltaroot;
- BigInteger p;
- BigInteger q;
- k = d1.multiply(e1).subtract(zero).divide(n1).add(one);
- pplusq = one.subtract(d1.multiply(e1)).divide(k).add(n1).add(one);
- deltaroot = sqrt(pplusq.multiply(pplusq).subtract(n1.multiply(four)));
- p = pplusq.add(deltaroot).divide(two);
- q = pplusq.subtract(deltaroot).divide(two);
- System.out.println(k + "--" + pplusq + "--" + p + " " + q);
- }
- public static BigInteger sqrt(BigInteger x) {
- BigInteger div = BigInteger.ZERO.setBit(x.bitLength()/2);
- BigInteger div2 = div;
- // Loop until we hit the same value twice in a row, or wind
- // up alternating.
- for(;;) {
- BigInteger y = div.add(x.divide(div)).shiftRight(1);
- if (y.equals(div) || y.equals(div2))
- return y;
- div2 = div;
- div = y;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement