note 111432 added to book.bc

From: Date: Tue, 19 Feb 2013 14:25:48 +0000
Subject: note 111432 added to book.bc
Groups: php.notes 
Request: Send a blank email to php-notes+get-193689@lists.php.net to get a copy of this message
Needed to compute some permutations and found the BC extension great but poor on functions, so untill this gets implemented here's the factorial function: <?php /* BC FACTORIAL * n! = n * (n-1) * (n-2) .. 1 [eg. 5! = 5 * 4 * 3 * 2 * 1 = 120] */ function bcfact($n){ $factorial=$n; while (--$n>1) $factorial=bcmul($factorial,$n); return $factorial; } print bcfact(50); //30414093201713378043612608166064768844377641568960512000000000000 ?> ---- Server IP: 69.147.83.199 Probable Submitter: 188.27.20.46 ---- Manual Page -- http://php.net/manual/en/book.bc.php Edit -- https://master.php.net/note/edit/111432 Del: integrated -- https://master.php.net/note/delete/111432/integrated Del: useless -- https://master.php.net/note/delete/111432/useless Del: bad code -- https://master.php.net/note/delete/111432/bad+code Del: spam -- https://master.php.net/note/delete/111432/spam Del: non-english -- https://master.php.net/note/delete/111432/non-english Del: in docs -- https://master.php.net/note/delete/111432/in+docs Del: other reasons-- https://master.php.net/note/delete/111432 Reject -- https://master.php.net/note/reject/111432 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#193689) next »