[Pharo-users] [Article] Speeding up factorial computation by changing the order of multiplications

Sven Van Caekenberghe sven at stfx.eu
Tue May 24 04:55:59 EDT 2016


> On 24 May 2016, at 10:21, Serge Stinckwich <serge.stinckwich at gmail.com> wrote:
> 
> Very nice article Sven !

Thanks, but it is just intro level (which is important too, of course).

> Can you contribute your code to the PolyMath project under the MIT
> Licence (and maybe some tests) ?

It is only one method. You can copy it over if you want. 

I am not 100% happy with the selector name #productTo: either. And there should probably be some error checking in a facade method before going into the loop, like

  self assert: upper isInteger.
  self assert: (self between: 1 and: upper).

Have you seen the Fast Factorial Functions website mentioned at the end ?

http://www.luschny.de/math/factorial/FastFactorialFunctions.htm

If I see that, I can only be very humble about the implementation in the article (which was based on some very old Lisp code that I had lying around - I did not come up with this myself).

Sven

> Thank you.
> 
> On Tue, May 24, 2016 at 8:57 AM, Sven Van Caekenberghe <sven at stfx.eu> wrote:
>> I just published a short, introduction level article,
>> 
>> Speeding up factorial computation by changing the order of multiplications.
>> 
>> This is a story about a small, seemingly innocent code change that speeds up a very simple computation. It is pretty magical and serves as an example of how things are not always what they seem.
>> 
>> https://medium.com/concerning-pharo/speeding-up-factorial-computation-by-changing-the-order-of-multiplications-f4da3a5576da#.l3nrk9oax
>> 
>> Enjoy,
>> 
>> Sven
>> 
>> --
>> Sven Van Caekenberghe
>> Proudly supporting Pharo
>> http://pharo.org
>> http://association.pharo.org
>> http://consortium.pharo.org
>> 
>> 
>> 
>> 
>> 
> 
> 
> 
> -- 
> Serge Stinckwich
> UCBN & UMI UMMISCO 209 (IRD/UPMC)
> Every DSL ends up being Smalltalk
> http://www.doesnotunderstand.org/
> 





More information about the Pharo-users mailing list