# exp. $n = 2; $e_n = exp($n); print "e^$n = $e_n\n"; sub my_factorial { my $n = shift; my $s=1; my $r=1; while ($s <= $n) { $r *= $s; $s++; } if($n == 0) { $r=0; } return $r; } sub my_exp_x { my $x = shift; my $max_iterations = shift; my $result = 1 + $x; my $i = 2; while ($i < $max_iterations) { $result += ($x ** ($i)) / (my_factorial($i)); $i++; } return $result; } print "test: ", my_exp_x($n,1000);
In reply to Re: Exponential Function Programming
by okram
in thread Exponential Function Programming
by Abulil
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |