Permalink
Browse files

Improved gen_fib() (Grame Hewson, GH #166).

  • Loading branch information...
1 parent e70412e commit 563d7ae0bd65fb9cfcaa7f7504a51f0e4784e860 @chromatic committed Oct 22, 2011
Showing with 5 additions and 2 deletions.
  1. +3 −0 CREDITS
  2. +2 −2 sections/closures.pod
View
@@ -209,3 +209,6 @@ E: btilly@gmail.com
N: Michael Lang
E: michi@jackal-net.at
+
+N: Graeme Hewson
+E: ghewson@wormhole.me.uk
View
@@ -132,15 +132,15 @@ elements you need:
sub gen_fib
{
- my @fibs = (0, 1, 1);
+ my @fibs = (0, 1);
return sub
{
my $item = shift;
if ($item >= @fibs)
{
- for my $calc ((@fibs - 1) .. $item)
+ for my $calc (@fibs .. $item)
{
$fibs[$calc] = $fibs[$calc - 2] + $fibs[$calc - 1];
}

0 comments on commit 563d7ae

Please sign in to comment.