I’m doing a task in a subject were fib(0) is defined to = 1. But that can’t be right? fib(0) is 0?
Program with fib(0) = 1; spits out fib(4) = 5
Program with fib(0) = 0; spits out fib(3) = 3
What is the correct definition?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’re correct. The Fibonacci sequence is formally defined with seed values
fib(0) = 0andfib(1) = 1. This is a requirement for the rest of the sequence to be right (and not offset by one or anything).In mathematics, the Fibonacci numbers, commonly denoted Fn, form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1.
Edit: I have to concede that there is another (much less common, and usually informal) way to define the sequence by seeding it with values 1 and 1, but this is not the conventional one by any means. It is certainly not preferred in all the formal mathematical definitions I’ve seen, like The On-Line Encyclopaedia of Integer Sequences.