Created
December 28, 2014 21:56
-
-
Save Sobak/7f3b1c6ffd951467005e to your computer and use it in GitHub Desktop.
Innovative implementation of factorial. Result of boredom and too much free time.
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) { | |
return eval('return '.implode(range(1, $num), '*').';'); | |
} | |
// more readable form | |
function factorial2($num) { | |
$operation = implode(range(1, $num), '*'); | |
return eval("return $operation;"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment