<?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); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter