Factorials and PHP

2007 April 19 at 02:47 » Tagged as :

When it comes to factorials Mysql struggles. Really struggles. Nothing is impossible but it certainly isn't easy to calculate values larger than 50! with mysql. So how does it's good friend PHP fare? Amazingly well. Using the arbitrary precision math (BCMath) functions of PHP you can calculate factorials at the drop of a hat. It's blistering speed is a pleasent surprise.

Using the arbitary precision math library. You can solve problem 20 at project Euler in the blink of an eye. Here is the code.