Tuesday, November 3, 2015

Filled Under:

Perl program to find the factorial of a number using recursion

Share
print "Enter a number: ";
$n=<STDIN>;
$t=$n;
$i=0;
$f=1;
while($i<$t)
{
$f=$f*$n;
$n--;
$i++;
}
print "Factorial is $f\n";

0 comments:

Post a Comment