[Tutor] operator, mult
col speed
ajarncolin at gmail.com
Wed Jan 28 02:25:08 CET 2009
That's what I thought , but I tried it to no avail. Plus the syntax is
wrong.
Thanks anyway
Colin
2009/1/28 John Fouhy <john at fouhy.net>
> 2009/1/28 col speed <ajarncolin at 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090128/9b63f67f/attachment.htm>
More information about the Tutor
mailing list