note 21946 added to ref.math
| From: | webkid%webkid.com@php.net | Date: | Fri, 31 May 2002 19:49:40 +0000 |
| Subject: | note 21946 added to ref.math | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-31309@lists.php.net to get a copy of this message | ||
I found it kind of irritating that PHP had no native functionality for a calculating Factorials.
Since I really didn't feel like loading the GMP library, I figured I'd write my own
function.
function fact($s){$r=(int)$s; for ($i=$r;$i--;$i>1){$r=$r*$i;} return $r;}
I think that's right... I havn't tested it extensively but it should work.
--
http://www.php.net/manual/en/ref.math.php
http://master.php.net/manage/user-notes.php?action=edit+21946
http://master.php.net/manage/user-notes.php?action=delete+21946
http://master.php.net/manage/user-notes.php?action=reject+21946