Package java.math

Examples of java.math.BigInteger.gcd()


          assertTrue("inverse less than zero: " + a + " inv mod "
              + mod + " equals " + inv, inv
              .compareTo(BigInteger.ZERO) >= 0);
        } catch (ArithmeticException e) {
          assertTrue("should have found inverse for " + a + " mod "
              + mod, !one.equals(a.gcd(mod)));
        }
            }
    }
  }
View Full Code Here


        long longPhase = Math.round(dashPhase);
        BigInteger gcd = BigInteger.valueOf(Math.round(dashArray[0]));
        int sum = 0;
        for (int i = 0; i < longArrLength; i++) {
            longArray[i] = Math.round(dashArray[i % dashArray.length]);
            gcd = gcd.gcd(BigInteger.valueOf(longArray[i]));
            sum += longArray[i];
        }

        if (dashPhase != 0) {
            gcd = gcd.gcd(BigInteger.valueOf(longPhase));
View Full Code Here

            gcd = gcd.gcd(BigInteger.valueOf(longArray[i]));
            sum += longArray[i];
        }

        if (dashPhase != 0) {
            gcd = gcd.gcd(BigInteger.valueOf(longPhase));
            longPhase /= gcd.longValue();
        }

        sum /= gcd.longValue();
View Full Code Here

//    }

    static BigInteger gcd(BigInteger[] args){
        BigInteger gcd=BigInteger.ZERO;
        for(int i=0;i<args.length;i++){
            gcd = gcd.gcd(args[i]);
        }
        return gcd;
    }

View Full Code Here

            }
        }
        BigInteger ZERO=BigInteger.ZERO;
        BigInteger GCD=ZERO;
        for(int i=0;i<N;i++){
            GCD=GCD.gcd(t[i].subtract(t[minI]));
        }
        BigInteger rem=t[minI].mod(GCD);
        BigInteger ans = rem.equals(ZERO)?ZERO:GCD.subtract(rem);
        String output=String.format("Case #%d: %s",line,ans.toString());
        writeln(output, OUTFILE);
View Full Code Here

    do {
      e = new BigInteger(bitLength, GENERATOR);
    } while(e.compareTo(BigInteger.ONE) <= 0
        || e.compareTo(phiN) >= 0
        || e.gcd(phiN).compareTo(BigInteger.ONE) != 0);

    BigInteger d = e.modInverse(phiN);

    keys[0] = new keyPair(n, e);
    keys[1] = new keyPair(n, d);
View Full Code Here

                ++currentSize;
            } while (pointer != start);
            counter += currentSize;
            temp = BigInteger.valueOf(currentSize);
            //calculate l.c.m.
            lcm = (lcm.divide(lcm.gcd(temp))).multiply(temp);
        }
        return lcm;
    }

    /**
 
View Full Code Here

                ++currentSize;
            } while (pointer != start);
            counter += currentSize;
            temp = BigInteger.valueOf(currentSize);
            //calculate l.c.m.
            lcm = (lcm.divide(lcm.gcd(temp))).multiply(temp);
        }
        return lcm;
    }

    /**
 
View Full Code Here

                ++currentSize;
            } while (pointer != start);
            counter += currentSize;
            temp = BigInteger.valueOf(currentSize);
            //calculate l.c.m.
            lcm = (lcm.divide(lcm.gcd(temp))).multiply(temp);
        }
        return lcm;
    }

    /**
 
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.