If this is something you are going to do repeatedly it may be worthwhile storing the result of each recursion for use later:

facts = array();

public function factorial($number) {
return $this->calculateFactorial($number);

private function calculateFactorial($number) {
if($number facts)) {
return $this->facts[$number];
} else {
$calculatedFactorial = ($number * $this->calculateFactorial($number-1));
$this->facts[$number] = $calculatedFactorial;
return ($calculatedFactorial);

$f = new Factorial();
echo $f->factorial(4);
echo $f->factorial(6);
echo $f->factorial(25);
echo $f->factorial(7);

This means if you already calculated any factorials for $number or less then you don't have to calculate them all again.