Tuesday, November 3, 2015

Filled Under:

Perl program to find the factorial of a number ("for" loop)

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

0 comments:

Post a Comment