from decimal import Decimal


def euler_totient(num, factors):
    """
    Given a number n and all its distinct prime factors, compute φ(n).
    The insight is that for every distinct prime factor p of a number n, the portion of numbers coprime to A "decays" by exactly (1/p).
    """

    totient = Decimal(num)
    for _factor in factors:
        totient *= Decimal(_factor - 1) / Decimal(_factor)
    return int(totient)