2009/1/28 col speed <ajarnco...@gmail.com>: > 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) * ... [...] > 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.
It seems pretty obvious that operator.mul is what they mean (based on what the reduce function does). Perhaps it's a typo? -- John. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor