[Haskell-cafe] Style

Marc A. Ziegert coeus at gmx.de
Sat Aug 25 01:34:10 EDT 2007


whops... i did check it, but
that was a copypaste mistake.

buggy:
> tm_parallelizable_v1 = \n -> sum . takeWhile (>0) $ map (div n) fives
> 	where fives = iterate (*5) 1

should be:
> tm_parallelizable_v1 = \n -> sum . takeWhile (>0) $ map (div n) fives
> 	where fives = iterate (*5) 5

- marc


Am Freitag, 24. August 2007 schrieben Sie:
> Hi Marc
> 
> First off, thanks for your reply.
> >> tm_parallelizable_v1 = \n -> sum . takeWhile (>0) $ map (div n) fives
> >> 	where fives = iterate (*5) 1
> Did you check this one? IMHO I think it's producing the 'wrong' answer.
> 
> *Main> tm_parallelizable_v1 100
> 124
> (0.00 secs, 0 bytes)
> 
> *Main> tm 100
> 24
> (0.00 secs, 0 bytes)
> 
> If comparing the result to the other variants is accepted as a sort
> of proof. ;-)
>  
> But calculating the number of trailing zero's of n! is a matter of
> counting powers of five in the factorized n!: f.e.:
> 
> 10! = 1 2 3 2^2 5 2*3 7 2^3 3^2 2*5
> --> 5^2 --> picking up enough powers of 2 --> (2*5)^2 = 100
> 
> So you will have to correct your 'fives' to f.e.
> 
> fives = tail $ iterate (*5) 1
> 
> 
> 
> Regards
> 
> 
> @@i
>  
> 
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070825/493bf06e/attachment-0001.bin


More information about the Haskell-Cafe mailing list