from sympy.ntheory.factor_ import trailing


def _test(n, base):
    """Miller-Rabin strong pseudoprime test for one base.
    Return False if n is definitely composite, True if n is
    probably prime, with a probability greater than 3/4.
    """

    n = int(n)
    if n < 2:
        return False
    # remove powers of 2 from n (= t * 2**s)
    s = trailing(n - 1)
    t = n >> s
    # do the Fermat test
    b = pow(base, t, n)
    if b == 1 or b == n-1:
        return True
    else:
        for j in range(1, s):
            b = (b**2) % n
            if b == n-1:
                return True
    return False