public long LCM(FactorTree other){
        FactorTree lcm = new FactorTree();
        for (long n : this.keySet()){
            if (other.containsKey(n)){
                int powerA = this.get(n);
                int powerB = other.get(n);
                int highest = (powerA<=powerB) ? powerB : powerA;
                lcm.put(n, highest);
            }
            else {
                lcm.put(n, this.get(n));
            }
        }
        for (long n : other.keySet()){
            if (!this.containsKey(n)){
                lcm.put(n, other.get(n));
            }
        }
        return lcm.getProduct();
    }