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.

**Input:**

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.

**Output:**

For each test case, there is only one line of input that will comprise of space separated elements of the Fibonacci series.

**Constraints:**

1<=T<=100

2<=N<10^8

**Example:**

**Input:**

3

5

15

50

**Output:**

0 1 1 2 3 5

0 1 1 2 3 5 8 13

0 1 1 2 3 5 8 13 21 34

**Explanation:**

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.

mantan_g | 267 |

tushki | 198 |

aksht7 | 182 |

ayush1101 | 128 |

namansharmacse17 | 110 |

ARUN_PUNDIR | 730 |

manishgupta8497 | 627 |

AMAN__JAIN | 625 |

Abhimanyu_kumar | 562 |

AJ786 | 541 |

blackshadows | 5335 |

Ibrahim Nash | 5223 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4584 |

Login to report an issue on this page.