Recursive subroutine : Recursive « Subroutine « Perl
- Perl
- Subroutine
- Recursive
Recursive subroutine
sub factorial
{
my $value = shift (@_);
return $value == 1 ? $value : $value * factorial ($value - 1);
}
$result = factorial(6);
print $result;
Related examples in the same category