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

}

}

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?

Continue Learning about Engineering