Fibonacci Between

Tough Dash, January 2023
Limits 1s, 512 MB

Given two numbers LL and RR, you must print all the Fibonacci numbers between LL and RR (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:

  • 0+1=10 + 1 = 1

  • 1+1=21 + 1 = 2

  • 1+2=31 + 2 = 3

  • 2+3=52 + 3 = 5

  • And so on.

Input

The input will contain two integers: LL and RR (0L<R1070 \le L < R \le 10^7). The input will be such that at least one Fibonacci number will be within this range.

Output

Print all Fibonacci numbers between LL and RR (inclusive).

Sample

InputOutput
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 [0,10][0, 10].


Submit

Login to submit.

Statistics

93% Solution Ratio
FAHIM.ctgEarliest, 1M ago
nazmulnnsFastest, 0.0s
hmdkamrulLightest, 5.6 MB
Shahe_NoorShortest, 218B
Toph uses cookies. By continuing you agree to our Cookie Policy.