I having written a perl code for a function e^x = 1 + x/1! + x^2/2! + x^3/3!+.. + x^n/n!
consider values for x = 1 and n =10. My problem is I am getting correct values for the numerator and denominator part but while dividing them into $factor. I am not getting the decimal values. Could you please correct me where I am making mistake.
($x, $n) = @ARGV; # for x=1 , n =10
say "\n Your entered values are ", $x, " ", $n;
for my $i (1..$n)
{
$numerator = $x**$i;
$denominator = Math::BigInt->new($i)->bfac();
$factor = int($numerator / $denominator); # tried it without typecasting then too noluck
$exp = $exp + $factor; #[$numerator/$denominator];
say $i, "\n Numerator :", $numerator, "Denominator :", $denominator, " Factor :", $factor, " EXP :", $exp;
$i++;
}