'Return the tuple (R, self/R) where R is the positive Rational
extracted from self.
Examples
>>> from sympy import sqrt
>>> sqrt(4 + 4*sqrt(2)).as_content_primitive()
(2, sqrt(1 + sqrt(2)))
>>> sqrt(3 + 3*sqrt(2)).as_content_primitive()
(1, sqrt(3)*sqrt(1 + sqrt(2)))
>>> from sympy import expand_power_base, powsimp, Mul
>>> from sympy.abc import x, y
>>> ((2*x + 2)**2).as_content_primitive()
(4, (x + 1)**2)
>>> (4**((1 + y)/2)).as_content_primitive()
(2, 4**(y/2))
>>> (3**((1 + y)/2)).as_content_primitive()
(1, 3**((y + 1)/2))
>>> (3**((5 + y)/2)).as_content_primitive()
(9, 3**((y + 1)/2))
>>> eq = 3**(2 + 2*x)
>>> powsimp(eq) == eq
True
>>> eq.as_content_primitive()
(9, 3**(2*x))
>>> powsimp(Mul(*_))
3**(2*x + 2)
>>> eq = (2 + 2*x)**y
>>> s = expand_power_base(eq); s.is_Mul, s
(False, (2*x + 2)**y)
>>> eq.as_content_primitive()
(1, (2*(x + 1))**y)
>>> s = expand_power_base(_[1]); s.is_Mul, s
(True, 2**y*(x + 1)**y)
See docstring of Expr.as_content_primitive for more examples.'

def as_content_primitive(self, radical=False, clear=True):

    (b, e) = self.as_base_exp()
    b = _keep_coeff(*b.as_content_primitive(radical=radical, clear=clear))
    (ce, pe) = e.as_content_primitive(radical=radical, clear=clear)
    if b.is_Rational:
        (h, t) = pe.as_coeff_Add()
        if h.is_Rational:
            ceh = (ce * h)
            c = self.func(b, ceh)
            r = S.Zero
            if (not c.is_Rational):
                (iceh, r) = divmod(ceh.p, ceh.q)
                c = self.func(b, iceh)
            return (c, self.func(b, _keep_coeff(ce, (t + ((r / ce) / ceh.q)))))
    e = _keep_coeff(ce, pe)
    if (e.is_Rational and b.is_Mul):
        (h, t) = b.as_content_primitive(radical=radical, clear=clear)
        (c, m) = self.func(h, e).as_coeff_Mul()
        (m, me) = m.as_base_exp()
        if ((m is S.One) or (me == e)):
            return (c, self.func(_keep_coeff(m, t), e))
    return (S.One, self.func(b, e))
