<?php function factorial ($number, $factorial = 1) { if ($number < 0) { throw new InvalidArgumentException('Number cannot be less than zero (0)'); } if ($number == 0) { return $factorial; } else { return factorial($number - 1, $factorial * $number); } }