programming-examples/perl/Subroutine/Recursive subroutine.pl
2019-11-15 12:59:38 +01:00

11 lines
165 B
Perl

sub factorial
{
my $value = shift (@_);
return $value == 1 ? $value : $value * factorial ($value - 1);
}
$result = factorial(6);
print $result;