From: HaPK Date: 2005-09-15T23:45:05+09:00 Subject: Re: Math: sum and faculty Daniel Schierbeck wrote: > Range#sum > ========= This could be done with Enumerable#inject. Your implementation assumes that range is for values of Float class. > Integer#faculty > =============== > > Implementation > -------------- > > class Integer > def faculty > self == 0 ? 1 : self * (self - 1).faculty > end > end > (1..self).inject(1) { |result, x| result*x } would be more compact. Am I missing something, but why "faculty" ? Why not factorial ?