August 1999 Perl Hardware Store Slide #24

         { my @fact = (1);
             sub factorial {
             my $n = shift;
             return $fact[$n] 
               if defined $fact[$n];
             $fact[$n] = 
               ($n == 0 ? 1 
                        : $n * factorial($n-1));
           }
         }


Next Copyright © 1998 M-J. Dominus