def int_to_bytes(n: int) -> bytes:
    """
    turn an integer into bytes

    :param n: the integer
    :return: the bytes
    """
    r = b''
    x = n
    while x > 0:
        r = bytes([x % 256]) + r
        x //= 256
    return r