Examples of gcd()


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

Examples of java.math.BigInteger.gcd()

        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

Examples of java.math.BigInteger.gcd()

            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

Examples of java.math.BigInteger.gcd()

//    }

    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

Examples of java.math.BigInteger.gcd()

            }
        }
        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

Examples of java.math.BigInteger.gcd()

    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

Examples of java.math.BigInteger.gcd()

                ++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

Examples of java.math.BigInteger.gcd()

                ++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

Examples of java.math.BigInteger.gcd()

                ++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

Examples of lipstone.joshua.parser.types.BigDec.gcd()

 
  private BigDec gcd(ConsCell input) throws ParserException {
    ArrayList<ConsCell> ints = input.splitOnSeparator();
    BigDec gcd = new BigDec(parser.run(ints.get(0)).toString());
    for (int i = 1; i < ints.size(); i++)
      gcd = gcd.gcd(new BigDec(parser.run(ints.get(i)).toString()));
    return gcd;
  }
 
  private BigDec lcm(ConsCell input) throws ParserException {
    ArrayList<ConsCell> ints = input.splitOnSeparator();
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.