Hi all,
I wrote a simple Perl code to find the factorial of a number.
Need feed back on the same.please correct me if i have done anything wrong
#!/usr/bin/perl
use warnings;
use strict;
my $fact=1;
print("Enter Number:");
my $num=<STDIN>;
if($num==0)
{
print("factorial of $num=$fact\n");
}
elsif($num<0)
{
print("please enter only positive integers \n");
}
else
{
for (1..$num)
{
$fact*=$_;
}
print("factorial of $num=$fact\n");
}
with Regards
Uday V G
--
*********************************************************
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
Just know they were wrong, and try to move on.
**********************************************************