Re: factorial

From: Date: Tue, 13 Jan 2004 18:49:35 +0000
Subject: Re: factorial
Groups: php.general.es 
Request: Send a blank email to general-es+get-44407@lists.php.net to get a copy of this message
esto está en inet <?php /* calculates n!/k! */ function factorial($n,$k='1'){
    /* cast args as string types */
    $n = (string) $n;
    $k = (string) $k;
    /* multiply iteratively */
    $result = '1';
    $k = bcadd($k,'1');
    for($xth=$k;bccomp($xth,$n)<1;$xth=bcadd($xth,'1')){
        $result = bcmul($result,$xth);
    }
    return $result; // string
} ?> si vas a usar factoriales, seguro que estas te sirven también, pues son para combinatoria saludos torno http://davidaltherr.net/web/php_functions/nPk/nPk_show.php http://davidaltherr.net/web/php_functions/nCk/nCk_show.php

« previous php.general.es (#44407) next »