Given a positive integer N, print the Fibonacci series till the number N. If N is a part of the series, print N as well.
The first line of input is an integer T, denoting the number of test cases. For each test case, input an integer N, denoting the number up to which Fibonacci needs to be printed.
For each test case, there is only one line of input that will comprise of space separated elements of the Fibonacci series.
0 1 1 2 3 5
0 1 1 2 3 5 8 13
0 1 1 2 3 5 8 13 21 34
In the first test case, 5 is the number up to which the series needs to be printed. 5 is also a part of the series hence the output is printed till 5.
In the second test case, the maximum element of Fibonacci series which is less than or equal to 15 is 13. The output is printed till 13.
Similarly, in the third test case, 34 is the maximum element less than or equal to 50. So, the output is printed till 34.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.