Initial term of end of fibonacci sequence (closed interval) [closed]

0

I have to make a list of exercises in C and Java, but I could not understand the logic in this exercise. Could someone help?

Request the user the initial term and the end term of the Fibonacci sequence (closed interval) and print the result.

Ex:     Finomacci Sequence → 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

Initial term → 4

Final term → 8

    
asked by anonymous 09.10.2014 / 17:15

1 answer

1

The Fibonacci sequence is defined as follows:

F(1) = 0
F(2) = 1
F(n) = F(n-1) + F(n-2), se n > 2

That is, the sequence begins with the terms 0 and 1 and from there the next terms are the sum of the previous two. For example:

F(4) = F(3) + F(2) = 1 + 1 = 2

Your exercise asks the user to enter two parameters, inicio and fim . What you have to print are the numbers F(n) to n between numbers inicio and fim . For example, if inicio = 4 and fim = 8 , as in your example, you have to print F(4), F(5), F(6), F(7), F(8) .

    
09.10.2014 / 17:20