-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Fri, Jun 13, 2003 at 01:49:02PM +0900, Jason Creighton wrote: > Also, I would probably implement it thus: > > class Integer > def factorial > (1..self).inject { |f, n| f * n } > end > end Actually, my original code does a (1..self).each for efficiency. I wrote the recursive one for my email because it displayed the "._!" method which I thought was cool. My original code makes ._! a method of Fixnum and not Integer because I certainly don't ever want to take the factorial of a Bignum. > .....just in case we want to calculate the factorials of numbers larger than > 2**30 - 1 :-) My point exactly. :) - -- Daniel Carrera | OpenPGP fingerprint: Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88 UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrera/pgp.html -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (SunOS) iD8DBQE+6VuvnxE8DWHf+OcRAtrEAKCqTQ/D6qBBMYemNTL+ciH+k1eG3gCgnsNq ILwksae9iM2btDmtFkn3Wcc= =FjwM -----END PGP SIGNATURE-----