Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 563d7ae0bd65fb9cfcaa7f7504a51f0e4784e860 1 parent e70412e
chromatic authored October 21, 2011
3  CREDITS
@@ -209,3 +209,6 @@ E: btilly@gmail.com
209 209
 
210 210
 N: Michael Lang
211 211
 E: michi@jackal-net.at
  212
+
  213
+N: Graeme Hewson
  214
+E: ghewson@wormhole.me.uk
4  sections/closures.pod
Source Rendered
@@ -132,7 +132,7 @@ elements you need:
132 132
 
133 133
     sub gen_fib
134 134
     {
135  
-        my @fibs = (0, 1, 1);
  135
+        my @fibs = (0, 1);
136 136
 
137 137
         return sub
138 138
         {
@@ -140,7 +140,7 @@ elements you need:
140 140
 
141 141
             if ($item >= @fibs)
142 142
             {
143  
-                for my $calc ((@fibs - 1) .. $item)
  143
+                for my $calc (@fibs .. $item)
144 144
                 {
145 145
                     $fibs[$calc] = $fibs[$calc - 2] + $fibs[$calc - 1];
146 146
                 }

0 notes on commit 563d7ae

Please sign in to comment.
Something went wrong with that request. Please try again.