Given two numbers and , you must print all the Fibonacci numbers between and (inclusive).
Although the number 1 appears twice in the sequence, print it only once if it falls in the given range.
You can generate the Fibonacci sequence by starting with 0 and 1. And then, add the last two numbers in the sequence every time to generate the following number.
For example:
And so on.
The input will contain two integers: and (). The input will be such that at least one Fibonacci number will be within this range.
Print all Fibonacci numbers between and (inclusive).
Input | Output |
---|---|
0 10 | 0 1 2 3 5 8 |
The numbers 0, 1, 2, 3, 5, 8 are part of the Fibonacci sequence and fall in the range . |