#K39217. Unique Sequence Generator

    ID: 26372 Type: Default 1000ms 256MiB

Unique Sequence Generator

Unique Sequence Generator

This problem requires you to generate a unique sequence defined by the recurrence:

\(a_1 = 1\) and for \(n \ge 2\), \(a_n = \Bigl(\prod_{i=1}^{n-1}a_i\Bigr) + 1\).

You are given several test cases. For each test case, you should compute the N-th number of this sequence.

For example, when \(N = 4\), the sequence is: 1, 2, 3, 7, ... because:

  • a1 = 1,
  • a2 = 1 + 1 = 2,
  • a3 = 1 * 2 + 1 = 3,
  • a4 = 1 * 2 * 3 + 1 = 7.

Your task is to implement the solution such that it reads input from standard input (stdin) and writes output to standard output (stdout).

inputFormat

The first line contains an integer T indicating the number of test cases. This is followed by T lines, each containing an integer N where you have to find the N-th element of the sequence.

outputFormat

For each test case, output the corresponding N-th number in the sequence on a new line.

## sample
3
1
2
4
1

2 7

</p>