On Mon, Sep 18, 2000 at 11:49:02AM -0400, Josh Goldberg wrote: > > my @cache = (1); > sub tayers { > my $x = shift; > @cache = (1); > return undef if $x < 0; > unless (defined $cache[$x]) { > my $p = $cache[$#cache]; > $cache[$_] = $p *= $_ for ($#cache+1..$x); > } > return $cache[$x]; > } Well, as I said before, this routine is silly. It has a cache, but it's written in such a way it cleans the cache each time. So, it's doing a lot of useless work. > sub abigail { > my ($r => $x) = (1, shift); > do {$r *= $x} while $x -- > 2; > $r; > } > > sub josh { > my $x=shift; > my $l=$x; > while ($l>1){$x*=--$l}; Why spend time multiplying something with 1? while ($l > 2) {$x *= --$l} ought to be slightly faster. > $x; > } Abigail ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe