# Error in fib.rb for 1.9

**URL:** <https://www.ruby-forum.com/t/error-in-fib-rb-for-1-9/124161>\
**Category:** Ruby\
**Created:** [December 25, 2007, 9:30pm UTC](https://www.ruby-forum.com/t/error-in-fib-rb-for-1-9/124161 "2007-12-25T21:30:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzakiya](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ec8ea/32.png) [@jzakiya](https://www.ruby-forum.com/u/jzakiya)\
**Post date:** [December 25, 2007, 9:30pm UTC](https://www.ruby-forum.com/t/error-in-fib-rb-for-1-9/124161/1 "2007-12-25T21:30:33Z")

</div>

1.9 compiles and runs great on PCLinuxOS on my Toshiba Satelite  
laptop: P4 1Gb

On cursory benchmarks, 1.9 is 2 ~ 8 times faster than 1.8.6 p111 on  
some simple tests.

In the process I noticed the 1.9 fib.rb file in the /benchmarks/other-  
lang directory is incorrect,  
though fib.rb is correct under the /samples directory in 1.8.6 p111

fib.rb – 1.9.0 incorrect fib(0)=1, should be fib(0)=0  
def fib n  
if n \< 3  
1  
else  
fib(n-1) + fib(n-2)  
end  
end

fib.rb – 1.8.6 p111 correct for fib(0…n)  
def fib n  
if n \< 2  
n  
else  
fib(n-1) + fib(n-2)  
end  
end

I see this error time and time again, though I continue to try to  
stamp it out.  
If the routine claims to produce the fibonacci numbers, produce ALL  
the correct ones.  
See about fibonacci series/numbers here;

[http://goldennumber.net/fibonser.htm](http://goldennumber.net/fibonser.htm)

> **[Fibonacci sequence](https://en.wikipedia.org/wiki/Fibonacci_number)**
>
> In mathematics, the Fibonacci sequence is a sequence in which each number is the sum of the two preceding ones. Numbers that are part of the Fibonacci sequence are known as Fibonacci numbers, commonly denoted Fn . The sequence commonly starts from 0 and 1, although some authors start the sequence from 1 and 1 or sometimes (as did Fibonacci) from 1 and 2. Starting from 0 and 1, the first few values in the sequence are:
> The Fibonacci numbers were first described in Indian mathematics, as early as ...
