first commit
This commit is contained in:
17
perl/Examples/Chap5/factorial-2
Normal file
17
perl/Examples/Chap5/factorial-2
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
###
|
||||
### factorial2
|
||||
###
|
||||
|
||||
## Chapter 5 section 4.2
|
||||
|
||||
sub factorial {
|
||||
my ($n) = @_;
|
||||
my $product = 1;
|
||||
until ($n == 0) {
|
||||
$product *= $n;
|
||||
$n--;
|
||||
}
|
||||
return $product;
|
||||
}
|
||||
Reference in New Issue
Block a user