Skip to content

Instantly share code, notes, and snippets.

@zmughal
Last active August 29, 2015 14:09
Show Gist options
  • Save zmughal/e531070e61d593663ce3 to your computer and use it in GitHub Desktop.
Save zmughal/e531070e61d593663ce3 to your computer and use it in GitHub Desktop.
Iteration is a pesky thing...it makes your algorithms slow. So what if I could
calculate factorials without iteration?
Save the following in a file, `chmod a+x` it and run like `./fact.pl 5`
Just don't pass in negative numbers or you'll slowly use up system resources.
#!/usr/bin/env perl
$_ = shift and print $_*`$0 @{[$_-1]}`||1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment