Next The Perl Hardware Store DC.pm Version 31

Caching Fixes Recursion

        @fib = (0, 1);
        sub fib {
          my ($n) = @_; 
          return $fib[$n] if defined $fib[$n];
          return $fib[$n] = fib($n-1) + fib($n-2);
        }


Next Copyright © 2003 M. J. Dominus