Bjorn Bringert wrote: > > > > Here's a much more inefficient version, but it has the merit of being > > very easy to understand: > > > > tm_silly n = length $ takeWhile (=='0') $ reverse $ show $ product [1..n] > > > You're rigth. I came up with that one too the first time. But for large value's of n it takes too much time. You may improve that (time) by using another product formula:
*Main> length $ takeWhile (=='0') $ reverse $ show $ foldl' (*) 1 [1..30000] 7498 (0.96 secs, 790685000 bytes) *Main> length $ takeWhile (=='0') $ reverse $ show $ product [1..30000] 7498 (4.05 secs, 792259140 bytes) But: *Main> tm 30000 7498 (0.00 secs, 524924 bytes) Thanks @@i _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe