private void divideByGCD() { if (weights.size() > 0) { int d = gcd(weights.get(0).getIntegerMass(), weights.get(1).getIntegerMass()); for (int i = 2; i < weights.size(); ++i) { d = gcd(d, weights.get(i).getIntegerMass()); if (d == 1) return; } precision *= d; for (ChemicalElement weight : weights) { weight.setIntegerMass(weight.getIntegerMass() / d); } } }
d = gcd(firstLongVal, weights.get(j).getIntegerMass()); for (int p = 0; p < d; p++) { // Need to start d Round Robin loops if (p == 0) {
private void computeLCMs() { final ChemicalElement first = weights.get(0); first.setL(1); first.setLcm(first.getIntegerMass()); for (int i = 1; i < weights.size(); i++) { final ChemicalElement weight = weights.get(i); int temp = first.getIntegerMass() / gcd(first.getIntegerMass(), weight.getIntegerMass()); weight.setL(temp); weight.setLcm(temp * weight.getIntegerMass()); } }