J
jzakiya
In the latest ruby-1.8.6-p388 source code I just downloaded
the file fib.rb; 2007-2-12 contains correct code:
------------------------------
# calculate Fibonacci(20)
# benchmark
def fib(n)
if n<2
n
else
fib(n-2)+fib(n-1)
end
end
print(fib(20), "\n")
---------------------------
The code in fib.(awk,pl,py.scm) is also correct.
But in the lastest ruby-1.9.1-p378 source code
the file fib.rb (and fib.(awk,pl,py,scm) files)
has the same date but the code has been changed to
give an incorrect value for fib(0), which should be 0:
--------------------
def fib n
if n < 3
1
else
fib(n-1) + fib(n-2)
end
end
fib(34)
--------------------
The correct series starts with '0' and is::
n | 0 1 2 3 4 5 6 7 8 9 10...
----------------------------------------------
fib(n) | 0 1 1 2 3 5 8 13 21 34 55,..
See for verification:
http://goldennumber.net/fibonser.htm
http://en.wikipedia.org/wiki/Fibonacci_number
This is troubling, because not only does the 1.9.1 code
not give the fully accurate results, but the changes to
the file doesn't show a newer/different data than the
file in the 1.8.6 source code. The dates are the same.
Is someone messing with the source code, or has the 1.9.1
line not been thoroughly tested/vetted to catch these
obvious errors/differences from the prior versions?
A BIG obvious question now is, what else has been changed
that no longer completely gives accurate answers/results?
the file fib.rb; 2007-2-12 contains correct code:
------------------------------
# calculate Fibonacci(20)
# benchmark
def fib(n)
if n<2
n
else
fib(n-2)+fib(n-1)
end
end
print(fib(20), "\n")
---------------------------
The code in fib.(awk,pl,py.scm) is also correct.
But in the lastest ruby-1.9.1-p378 source code
the file fib.rb (and fib.(awk,pl,py,scm) files)
has the same date but the code has been changed to
give an incorrect value for fib(0), which should be 0:
--------------------
def fib n
if n < 3
1
else
fib(n-1) + fib(n-2)
end
end
fib(34)
--------------------
The correct series starts with '0' and is::
n | 0 1 2 3 4 5 6 7 8 9 10...
----------------------------------------------
fib(n) | 0 1 1 2 3 5 8 13 21 34 55,..
See for verification:
http://goldennumber.net/fibonser.htm
http://en.wikipedia.org/wiki/Fibonacci_number
This is troubling, because not only does the 1.9.1 code
not give the fully accurate results, but the changes to
the file doesn't show a newer/different data than the
file in the 1.8.6 source code. The dates are the same.
Is someone messing with the source code, or has the 1.9.1
line not been thoroughly tested/vetted to catch these
obvious errors/differences from the prior versions?
A BIG obvious question now is, what else has been changed
that no longer completely gives accurate answers/results?