in reply to Re^2: Exponential Function Programming
in thread Exponential Function Programming
x to the power of n is done via:
$x ** $n
or
You need to do this, though, "infinite" times, reason why I provided a parameter to "stop" after a certain time.sub x_power_n { my $x = shift; my $n = shift; my $result = $x; my $i = 1; while ($i < $n) { $result *= $x; $i++; } return $result; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Exponential Function Programming
by ikegami (Patriarch) on Nov 22, 2007 at 19:38 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |
In Section
Seekers of Perl Wisdom