def mode_digit(n):
    """
    This function takes an integer number n and
    returns the digit that appears most frequently in that number.
    """
    if abs(n) < 10:
        return n
    if n < 0:
        n = n * -1
    counts = [0] * 10
    while n != 0:
        digit = n % 10
        counts[digit] += 1
        n = n // 10
    max_val = max(counts)
    return max([i for i, j in enumerate(counts) if j == max_val])