In the Fibonacci sequence, is fib(0) 0 or 1 ?

前端 未结 10 1777
南旧
南旧 2020-12-14 15:11

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 w         


        
10条回答
  •  有刺的猬
    2020-12-14 15:52

    From the Fibonacci number entry on Wikipedia:

    In mathematics, the Fibonacci numbers are the following sequence of numbers:

    alt text

    By definition, the first two Fibonacci numbers are 0 and 1, and each remaining number is the sum of the previous two. Some sources omit the initial 0, instead beginning the sequence with two 1s.

    In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation

    alt text

    with seed values

    alt text

提交回复
热议问题