From: Trans Date: 2005-11-06T02:07:11+09:00 Subject: Re: Fun with Permutations Sorry it took me some time to get to this. I've been quite busy. This is very interesting and I'll see that it gets into Facets. I think the trade off is worth it too. But even better I think it can be improved. I recently got an interesting email (that I've also been meaning to get to) on the efficency of factorial algorithms, Malte Milatz wrote: On a German Ruby board, we've been discussing about the best way to compute the factorial of a number. While I don't suppose you to understand German, it would be nice if you had a look at the code and the benchmarks at . The result of our research seems to be that using inject is a highly inefficient way in this case because the block for Enumerable#inject takes two arguments. This may be a good reason to revise the method found in 'facet/integer/fact'. Note that we discarded the nil assignments seen in the first post, for they didn't really improve things. In addition murphy changed the benchmark to compute only up to 12! because tests on higher factorials will be likely to be only tests on Bignum arithmetics. ;; So in your formuation I see an inject with factorial in it. Perhaps a little coding challenge to speed it up. And I've just added the new factorial code to facets: def factorial return 0 if zero? f = 1 2.upto(self) { |n| f *= n } f end That should help a good bit. T.