answersLogoWhite

0


Best Answer

#!/usr/bin/perl

print factorial($ARGV[11]);

sub factorial {

my($num) = @_;

if($num == 1) {

return 1; # stop at 1, factorial doesn't multiply times zero

} else {

return $num * factorial($num - 1); # call factorial function recursively

}

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a C-like program fragment that calculate the factorial function for argment 12 with do while loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering