From: Justin Collins Date: 2009-07-12T18:38:41+09:00 Subject: Re: Fibonacci numbers - newbie question. salai wrote: > Dear All, > > I have two Fibonacci method, and I got different result. > > What wrong in my code.? > > def fib(n) > if n < 2 > 1 > else > fib(n-2) + fib(n-1) > end > end > > puts fib(10) # ---> 89 > > > def fib1(x) > return x if x < 2 > return fib1(x- 1) + fib1(x - 2) > end > > > > puts fib1(10) # --> 55 > > > regards, > salai Notice the difference between the two when x is 0. -Justin