'Return ``(R, self/R)`` where ``R``` is the Rational GCD of ``self```.
``R`` is collected only from the leading coefficient of each term.
Examples
>>> from sympy.abc import x, y
>>> (2*x + 4*y).primitive()
(2, x + 2*y)
>>> (2*x/3 + 4*y/9).primitive()
(2/9, 3*x + 2*y)
>>> (2*x/3 + 4.2*y).primitive()
(1/3, 2*x + 12.6*y)
No subprocessing of term factors is performed:
>>> ((2 + 2*x)*x + 2).primitive()
(1, x*(2*x + 2) + 2)
Recursive subprocessing can be done with the as_content_primitive()
method:
>>> ((2 + 2*x)*x + 2).as_content_primitive()
(2, x*(x + 1) + 1)
See also: primitive() function in polytools.py'

def primitive(self):

    terms = []
    inf = False
    for a in self.args:
        (c, m) = a.as_coeff_Mul()
        if (not c.is_Rational):
            c = S.One
            m = a
        inf = (inf or (m is S.ComplexInfinity))
        terms.append((c.p, c.q, m))
    if (not inf):
        ngcd = reduce(igcd, [t[0] for t in terms], 0)
        dlcm = reduce(ilcm, [t[1] for t in terms], 1)
    else:
        ngcd = reduce(igcd, [t[0] for t in terms if t[1]], 0)
        dlcm = reduce(ilcm, [t[1] for t in terms if t[1]], 1)
    if (ngcd == dlcm == 1):
        return (S.One, self)
    if (not inf):
        for (i, (p, q, term)) in enumerate(terms):
            terms[i] = _keep_coeff(Rational(((p // ngcd) * (dlcm // q))), term)
    else:
        for (i, (p, q, term)) in enumerate(terms):
            if q:
                terms[i] = _keep_coeff(Rational(((p // ngcd) * (dlcm // q))), term)
            else:
                terms[i] = _keep_coeff(Rational(p, q), term)
    if (terms[0].is_Number or (terms[0] is S.ComplexInfinity)):
        c = terms.pop(0)
    else:
        c = None
    _addsort(terms)
    if c:
        terms.insert(0, c)
    return (Rational(ngcd, dlcm), self._new_rawargs(*terms))
