def digital_root(n):
    """
    Return the sum of the digits of n, repeated until one digit remains.
    This happens to be the same as n % 9 except in the case where the
    modulus is 0 and n is greater than 0, in which case the result
    is 9.
    """

    if n == 0:
        return 0
    mn = n % 9
    return 9 if mn == 0 else mn