Hello there,
 I got the following function while googling:

def totient(n):
    """calculate Euler's totient function.

    If [[p_0,m_0], [p_1,m_1], ... ] is a prime factorization of 'n',
    then the totient function phi(n) is given by:

        (p_0 - 1)*p_0**(m_0-1) * (p_1 - 1)*p_1**(m_1-1) * ...

    >>> phi(1)
    1
    >>> phi(10)
    4
    """
    from operator import mult

    if n == 1: return 1

    return reduce(mult, [(p-1) * p**(m-1) for p,m in prime_factors_mult(n)])


I already have the "prime_factors" function. The problem is that I cannot
find "mult". I tried using "mul" which is in "operator" but that is
obviously not the same thing.
Could there be a similar thing somewhere other than "operator"?

Thanks a lot
Colin
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to