Skip to content

Instantly share code, notes, and snippets.

@jamierumbelow
Forked from jcf/Math.factorial.rb
Created February 19, 2010 18:18
Show Gist options
  • Save jamierumbelow/309003 to your computer and use it in GitHub Desktop.
Save jamierumbelow/309003 to your computer and use it in GitHub Desktop.
func Factorial(num int) int {
if num == 0 {
return 1;
} else {
return num * Factorial(num - 1);
}
}
<?php
function factorial($num) {
return ($num == 0) ? 1 : $num * factorial($num - 1);
}
def factorial(num):
return (1 if num == 0 else num * factorial(num - 1))
module Math
def self.factorial(f)
f == 0 ? 1 : f * factorial(f - 1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment