#!/usr/bin/perl use warnings; my $n=shift; my $f=1; for($i=2; $i<=$n; $i++) { $f*=$i; } print "$f\n";
#!/usr/bin/perl use warnings; sub factorial { my $n=shift; return 1 unless $n; return $n*factorial($n-1); } print factorial(shift @ARGV), "\n";
#!/usr/bin/perl use warnings; sub factorial { return $_[0]? $_[0]*factorial($_[0]-1): 1; } print factorial(shift @ARGV), "\n";