Skip to content

Instantly share code, notes, and snippets.

@airencracken
Created May 27, 2014 07:06
Show Gist options
  • Save airencracken/62799993daf6c776b1bb to your computer and use it in GitHub Desktop.
Save airencracken/62799993daf6c776b1bb to your computer and use it in GitHub Desktop.
Perl Factorial with Ternary
#!/usr/bin/env perl
use 5.10.0;
use strict;
use warnings;
my $input = shift @ARGV || die "Give me a number\n";
sub factorial {
my $n = shift;
$n == 0 ? 1 : $n * factorial($n - 1);
}
say factorial($input);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment