Professional Documents
Culture Documents
Sorcerer Sequence
Sorcerer Sequence
Sorcerer Sequence is a series of integer numbers in which the first term starts with a positive integer and
the remaining terms are generated from the immediate previous term using the below recurrence relation :
1/2
ak+1 = ak for even ak
3/2
ak+1 = ak for odd ak
Given a number N your task is to print the space-separated Sorcerer Sequence using this number as the
first term of the sequence.
Input Format
First-line contains an integer T , where T is the number of test cases.
Output Format
For each test case, in a new line print, the space-separated Sorcerer sequence for number N as the first
term of the sequence.
Constraints
1 <= T <= 100
Time Limit
1 second
Example
Input1
Output
8 2 1
5 11 36 6 2 1
Explanation
In the first test case, we start with 8 and use the above formula to get the next terms, until we reach 1.
In the second test case, we start with 5, next digit is (sqrt(5)*sqrt(5)*sqrt(5)) = 11, and so on.