def factor_octets(octet_array, is_ipv6):
    """Convert each decimal octet into a factor of the
    divisor (16 or 256) and a remainder"""
    if is_ipv6:
        divisor = 256
    else:
        divisor = 16
    factord_octet_array = []
    for i in range(len(octet_array)):
        factord_octet_array.extend([octet_array[i] // divisor,
                                    octet_array[i] % divisor])
    return factord_octet_array