code: function(toPolynomial) {
              //get the first nozero coefficient and returns its power
              var fnz = function(a) {
                      for(var i=0; i<a.length; i++)
                          if(!a[i].equals(0)) return i;
                  },
                  ca = [];
              for(var i=0; i<this.coeffs.length; i++) {
                  var c = this.coeffs[i];
                  if(!c.equals(0) && ca.indexOf(c) === -1) ca.push(c);
              }
              var p = [core.Math2.QGCD.apply(undefined, ca), fnz(this.coeffs)].toDecimal(); 
  
              if(toPolynomial) {
                  var parr = [];
                  parr[p[1]-1] = p[0];
                  p = Polynomial.fromArray(parr, this.variable).fill();
              }
  
              return p;
          }
docs: Returns the Greatest common factor of the polynomial
  @param {bool} toPolynomial - true if a polynomial is wanted
  @returns {Frac|Polynomial}