In the following sequence, each number (except the first two) is the sum of the previous two number: 0, 1, 1, 2, 3, 5, 8, 13, – This sequ

Question

In the following sequence, each number (except the first two) is the sum of the previous two number: 0, 1, 1, 2, 3, 5, 8, 13, …. This sequence is known as the Fibonacci sequence. Given the positive integers m and n (with m < n) create a list consisting of the portion of the Fibonacci sequence greater than or equal to m and less than or equal to n. For example, if m is 3 and n is 6, then the list would be [3, 5] and if m is 2 and n is 20, then the list would be [2, 3, 5, 8, 13]. Associate the list with the variable fib.

in progress 0
Rose 3 weeks 2021-10-01T13:20:33+00:00 1 Answer 0

Answers ( )

    0
    2021-10-01T13:21:41+00:00

    Answer:

    Fibonacci series ranging from m to n where m<n assuming n=200 and m=100 .

    Step-by-step explanation:

    #you have to produce a fibonacci series from 0 to n as follows:

    k = [0,1]

    fib=[]

    n=200

    m=100

    for p in range(1, n+1):

       y = k[p]+k[p-1]

       if x > n:

          break

       else:

           k.append(y)

    # Now to single out those fibonacci series between m and n in a list #associated with the variable fib, do the following:  

    for p in range(0, len(k)):    # p ranging from 0 to the last index of k

       if k[p] >= m and k[p] <= n:

    fib.append(k[p]) #append only those series within m and n to the    

                               #variable fib

    print fib   #this will display the list created

Leave an answer

45:7+7-4:2-5:5*4+35:2 =? ( )