def _p_r_log_helper(x, a, b, alpha, beta, n, p):
    """
    Step function used with the pollard rho discrete log algorithm
    """
    if x % 3 == 1:
        f = ((beta * x) % p, a, (b + 1) % n)
    elif x % 3 == 0:
        f = ((x * x) % p, (2 * a) % n, (2 * b) % n)
    else:
        f = ((alpha * x) % p, (a + 1) % n, b)
    return f