6 ms·
I don't think it's explicitly wrong; I've seen both fib(0) = 1 and fib(0) = 0 before. Wikipedia shows: By definition, the first two Fibonacci numbers are 0
by jpd 16y ago
I don't think it's explicitly wrong; I've seen both fib(0) = 1 and fib(0) = 0 before. Wikipedia shows:
By definition, the first two Fibonacci numbers are 0
and 1, and each subsequent number is the sum of the
previous two. Some sources omit the initial 0, instead
beginning the sequence with two 1s.
- amouat 16y agoI think it's still wrong by that definition. I think it is just saying fib(1) is the first number, not fib(0). fib(2) should never be 2. EDIT: Actually, I think you're right: it's just an index thing (do we start at 1 or 0) - I was confusing the index of 2 with the value of 2.