Created
August 19, 2014 21:11
-
-
Save webinista/e8b8823401802a89586c to your computer and use it in GitHub Desktop.
Factorial in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function factorial($num){ | |
$rng = range(1,$num); | |
return array_product($rng); // array_product function requires PHP5.1.0+ | |
} | |
print factorial(10); // 3628800 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment