BioPHP - Factorial
Original code submitted by josebaCode bellow is covered by GNU GPL v2 license.
Description
Last change: 2010/10/18 17:04 | Edit description | Recent Changes | Original descriptionComputes factorial of number
Code
Last change: 2010/10/18 17:04 | Edit Code | Recent Changes | Download | Original codefunction factorial( $x ) {
$tmp = 1;
if( $x == 0 ) {
$tmp = 1;
}
else if( $x < 0 ) {
return -1;
}
else {
for( $i=1; $i < $x+1; $i++ ) {
$tmp *= $i;
}
}
return $tmp;
}