Ask Question
22 September, 05:24

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.

+2
Answers (1)
  1. 22 September, 05:44
    0
    Fibonacci series ranging from m to n where m
    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
Know the Answer?
Not Sure About the Answer?
Find an answer to your 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 ...” in 📗 Mathematics if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers