[Vit-discuss] Top Ruby Projects algorithm?

Todd Willey xtoddx at gmail.com
Fri Aug 25 16:10:42 EDT 2006


On 8/25/06, Martin DeMello <martindemello at gmail.com> wrote:
> On 8/26/06, James Edward Gray II <james at grayproductions.net> wrote:
> > On Aug 25, 2006, at 2:37 PM, Martin DeMello wrote:
> >
> > > On 8/26/06, John W. Long <ng at johnwlong.com> wrote:
> > >>
> > >> Suggestions?
> > >
> > > a = "Goodbye cruel world"
> > > a["Goodbye cruel"] = "Hello"
> > > puts a
> >
> > But isn't that just what we already have?
>
> Oops - missed that. Sorry for the noise.
>
> a = 1
> 2.upto(1000) {|i| a = a * i}
> puts a

why not:
puts (2...1000).inject(1){|fact,current| fact * current}

>
> martin
> _______________________________________________
> vit-discuss mailing list
> vit-discuss at rubyforge.org
> http://rubyforge.org/mailman/listinfo/vit-discuss
>


More information about the vit-discuss mailing list