"Mathieu Bouchard" <matju / sympatico.ca> schrieb im Newsbeitrag 
news:Pine.LNX.4.21.0503262110380.5161-100000 / mondrian.artengine.ca...
>
> On Fri, 18 Mar 2005, Phrogz wrote:
>> Aside - whatever the name, what an excellent, versatile function! For
>> example, the linked-to geometric series sum at
>> http://www.brpreiss.com/books/opus8/programs/pgm02_06.txt can be
>> written in a more terse and (IMO) more ruby-esque way as simply:
>> def geometric_series_sum( x, n )
>> (0..n).inject(0){ |sum,i| sum+x**i }
>> end
>
> And even shorter,
>
> def geometric_series_sum(x,n) (x**(n+1)-1)/(x-1) end

LOL ... and more efficient also.  Know your math. :-)

Cheers

    robert