Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Tim Peters
[Tim Peters] >> You would in this case, and that would be wrong. In fp you'd get an >> approximation to the exact n * (1./5 + 1./5**2 + ...) == n/4. (use >> the rule for the sum of an infinite geometric series). For example, >> that way you'd compute that 4! == 24 has 4/4 == 1 trailing zero, >>

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Christian Tschabuschnig
[Tim Peters] > You would in this case, and that would be wrong. In fp you'd get an > approximation to the exact n * (1./5 + 1./5**2 + ...) == n/4. (use > the rule for the sum of an infinite geometric series). For example, > that way you'd compute that 4! == 24 has 4/4 == 1 trailing zero, > inste

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Tim Peters
[Tim Peters] >> For a fun :-) exercise, prove that the number of trailing zeroes in n! >> is the sum, from i = 1 to infinity, of n // 5**i (of course as soon as >> you reach a value of i such that n < 5**i, the quotient is 0 at that i >> and forever after). >> >> In this case, >> >> 100 // 5 + 100

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Christian Tschabuschnig
Tim Peters wrote: > [Dick Moores, computes 100 factorial as > > 9332621544394415268169923885626670049071596826438162146859296389521753229915608941463976156518286253697920827223758251185210916864 > > but worries about all the trailing zeros] > >> Yes, I'm sure you a

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Tim Peters
[Dick Moores, computes 100 factorial as 9332621544394415268169923885626670049071596826438162146859296389521753229915608941463976156518286253697920827223758251185210916864 but worries about all the trailing zeros] > Yes, I'm sure you are. I'd forgotten about all tho

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Dick Moores
At 04:50 PM 8/18/2006, Christian Tschabuschnig wrote: > >> > 9332621544394415268169923885626670049071596826438162146859296389521753229915608941463976156518286253697920827223758251185210916864 > >>> Still not exactly correct! I'm bewildered. > >>> > >> The results look t

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Christian Tschabuschnig
>> 9332621544394415268169923885626670049071596826438162146859296389521753229915608941463976156518286253697920827223758251185210916864 >>> Still not exactly correct! I'm bewildered. >>> >> The results look the same to me >> why do you think they're not correct? >> what is

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Dick Moores
At 04:24 PM 8/18/2006, Luke Paireepinart wrote: >Dick Moores wrote: > > But here's the revised precisionFactorial.py: > > > > > > # 1precisionFactorial.py > > > > import decimal > > > > def d(x): > > return decimal.Decimal(str(x)) > > > > def fact(n): > > product

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Luke Paireepinart
Dick Moores wrote: > At 02:41 PM 8/18/2006, Bob Gailer wrote: > >> Dick Moores wrote: >> >>> As an exercise that I thought would help me understand the decimal >>> module, I've been trying write a script (precisionFactorial.py) >>> that uses a modified fact(n) to compute precise factorial

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Dick Moores
At 02:41 PM 8/18/2006, Bob Gailer wrote: >Dick Moores wrote: >>As an exercise that I thought would help me understand the decimal >>module, I've been trying write a script (precisionFactorial.py) >>that uses a modified fact(n) to compute precise factorials >What do you mean by "precise factorials

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Bob Gailer
Dick Moores wrote: > As an exercise that I thought would help me understand the decimal > module, I've been trying write a script (precisionFactorial.py) that > uses a modified fact(n) to compute precise factorials What do you mean by "precise factorials"? Python's long integer should handle th

[Tutor] puzzled again by decimal module

2006-08-18 Thread Dick Moores
As an exercise that I thought would help me understand the decimal module, I've been trying write a script (precisionFactorial.py) that uses a modified fact(n) to compute precise factorials using the decimal module. I''m getting nowhere fast, and don't understand why. Here's what I have so far: