#K12006. Calculate Sequence Value
Calculate Sequence Value
Calculate Sequence Value
You are given a positive integer N. Starting with an integer S=1, you need to perform N operations. In the i-th operation (1 ≤ i ≤ N), if S is odd, add i to S (i.e. S = S + i), otherwise, multiply S by i (i.e. S = S × i).
Formally, for every i from 1 to N,
\[ S = \begin{cases} S + i, & \text{if } S \text{ is odd},\\ S \times i, & \text{if } S \text{ is even}. \end{cases} \]
Your task is to compute the final value of S after N operations for each test case.
inputFormat
The first line contains a single integer T
representing the number of test cases. Each of the next T
lines contains a single integer N
indicating the number of operations.
outputFormat
For each test case, output the final value of S
after performing N
operations. Each result should be printed on a separate line.
1
1
2
</p>