The Fibonacci sequence (Fibonacci sequence), which was introduced by the mathematician Leonardo's Fibonacci (Leonardoda Fibonacci) as an example of rabbit reproduction, is also known as the "rabbit sequence", referring to a sequence of 0, 1, 1, 2, 3, 5, 8, 13, 21. 、...... In mathematics, the Fibonacci sequence is defined recursively as follows: F (0) =0,f (1) =1,f (n) =f (n-1) +f (n-2) (n≥2,n∈n*) in modern physics, quasi-crystalline structure, chemistry and other fields, the Fibonacci sequence has a direct application.
The characteristics of the series: the 1th item is 0, the 2nd item is the first 1, starting with the 3rd item, each item is equal to the sum of the first two items.
Title Description:
There is a staircase of a total of n-level, just at the beginning of you in the first level, if you can only step up one level or two, to embark on the nth level, how many methods?
Note: There are 0 ways to go from one level to the next.
function Taijie (n) { var arr=[]; arr[0]=0; arr[1]=0; Arr[2]=1; arr[3]=2; for (Var i=4;i<=n;i++) { arr[i] =arr[i-1]+arr[i-2]; } return arr[n]; }
Fibonacci sequence solves the problem of the upper steps