in reply to Exponential Function Programming
I think that this is more noble and incomprehensible :>)
#!/usr/bin/perl use strict; use warnings; sub exp_ { my $x = shift; my ($d, $ret, $i) = (1.0, 1); while ($ret - $d != $ret) { $d *= $x/++$i; $ret += $d; } return $ret; } for (1..100) { print "exp($_) = ".exp_($_)."\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Exponential Function Programming
by ikegami (Patriarch) on Nov 22, 2007 at 20:21 UTC | |
by pajout (Curate) on Nov 23, 2007 at 18:21 UTC | |
by ikegami (Patriarch) on Nov 23, 2007 at 18:44 UTC | |
by pajout (Curate) on Nov 23, 2007 at 19:05 UTC |
In Section
Seekers of Perl Wisdom