Skip to content

Instantly share code, notes, and snippets.

@NEbere NEbere/factorial.php
Created Feb 11, 2016

What would you like to do?
The factorial of a given number
function factorial($n) {
$factorial = 1;
for($i = $n; $i >= 1; $i--){
$factorial = $factorial * $i;
echo "Factorial of $n is $factorial";
//calling the function
//returns 120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.