Electrical Engineering Question:
Download Questions PDF

Write the code for finding the factorial of a passed integer. Use a recursive subroutine?

Answer:

// BEGIN PERL SNIPET

sub factorial {
my $y = shift;
if ( $y > 1 ) {
return $y * &factorial( $y - 1 );
} else {
return 1;
}
}

// END PERL SNIPET

Download Electrical Engineering Interview Questions And Answers PDF

Previous QuestionNext Question
Write the code to sort an array of integers?In C, explain the difference between the & operator and the * operator?