Re: [Tutor] operator, mult

2009-01-28 Thread col speed
Thanks John, That sorted me out, sometimes I just can't get things worked out in my head, then get a sense of "instant enlightenment", which your comments did for me. I am ashamed to say I was using the wrong prime factors function, then changing the mult to mul all started to make sense. Thanks ag

Re: [Tutor] operator, mult

2009-01-28 Thread John Fouhy
2009/1/29 col speed : [...] > What I expected "mult" to do was (somehow)to work out what the powers of > the prime factors would be. Another reason I didn't think it was "mul" is > the part that says " prime_factors_mult(n)" as the prime_factors function > is just "prime_factors(n)" - without th

Re: [Tutor] operator, mult

2009-01-28 Thread col speed
hat *should *work out the number of coprimes of 144 *Please don't bother too much about this. I've included it for your information as syou have replied, but I think I'll leave it until I understand a bit more - I'm biting off more than I can chew.* Message: 6 Date: Wed,

Re: [Tutor] operator, mult

2009-01-28 Thread Alan Gauld
"col speed" 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 "mu

Re: [Tutor] operator, mult

2009-01-27 Thread col speed
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 > 2009/1/28 col speed : > > Hello there, > > I got the following function while googling: > > > > def totient(n): > > """calculate Euler's totient function. > > > > If

Re: [Tutor] operator, mult

2009-01-27 Thread John Fouhy
2009/1/28 col speed : > 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_

[Tutor] operator, mult

2009-01-27 Thread col speed
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) * .