note 65923 added to ref.math

From: Date: Wed, 10 May 2006 08:15:36 +0000
Subject: note 65923 added to ref.math
Groups: php.notes 
Request: Send a blank email to php-notes+get-111034@lists.php.net to get a copy of this message
I think, this is the optimal code for calculating factorials: <?php function fact($int){ if($int<2)return 1; for($f=2;$int-1>1;$f*=$int--); return $f; }; ?> And another one for calculating the $int-th Fibonacci-number: <?php function fib($int){ static $fibTable=array(); return empty($fibTable[$int])?$fibTable[$int] = $int>1?fib($int-2)+fib($int-1):1:$fibTable[$int]; }; ?> ---- Server IP: 195.70.37.52 Probable Submitter: 62.77.205.248 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/ref.math.php Edit -- http://master.php.net/note/edit/65923 Del: integrated -- http://master.php.net/note/delete/65923/integrated Del: useless -- http://master.php.net/note/delete/65923/useless Del: bad code -- http://master.php.net/note/delete/65923/bad+code Del: spam -- http://master.php.net/note/delete/65923/spam Del: non-english -- http://master.php.net/note/delete/65923/non-english Del: in docs -- http://master.php.net/note/delete/65923/in+docs Del: other reasons-- http://master.php.net/note/delete/65923 Reject -- http://master.php.net/note/reject/65923 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#111034) next »