"col speed" <ajarnco...@gmail.com> wrote

I got the following function while googling:

def totient(n):
   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".

Given it says mult is in operators then it must be (or have been
in a previous version) a standard Python operator that is intended.
Did it menton which version of Python was used? Is it an old site?

I tried using "mul" which is in "operator" but that is
obviously not the same thing.

How so? What did it do?

from operator import mul
reduce(mul,[1,2,3,4])
24

Does what I would expect it to do... What do you think mult should do?

Alan G



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to