Help for this page

Select Code to Download


  1. or download this
        sub fibo
        {
            my ($n, $a, $b) = (shift, 0, 1);
            ($a, $b) = ($b, $a + $b) while $n-- > 0;
            $a;
        }
    
  2. or download this
    use strict;
    use warnings;
    use Memoize;
    ...
      ($a, $b) = ($b, $a + $b) while $n-- > 0;
      $a;
    }
    
  3. or download this
    use strict;
    use warnings;
    use Memoize;
    ...
      return $n if $n < 2;
      return fib($n - 1) + fib($n - 2);
    }