#K46742. Consecutive Sum Representations

    ID: 28044 Type: Default 1000ms 256MiB

Consecutive Sum Representations

Consecutive Sum Representations

Given a positive integer \( n \), determine how many distinct ways it can be expressed as the sum of one or more consecutive positive integers.

For example, if \( n = 15 \), there are 4 representations:

  • 15
  • 7 + 8
  • 4 + 5 + 6
  • 1 + 2 + 3 + 4 + 5

In general, if a sequence starts with \( a \) and has \( k \) terms, then its sum is given by:

[ n = a + (a+1) + \cdots + (a+k-1) = ka + \frac{k(k-1)}{2}. ]

We require \( a > 0 \) and \( a \) to be an integer. Your task is to count the number of such valid sequences for a given \( n \).

inputFormat

The input is read from standard input (stdin) and has the following format:

T
n1
n2
... 
 nT

Here, \( T \) is the number of test cases, and each \( n_i \) is a positive integer for which you need to compute the number of representations as the sum of consecutive positive integers.

outputFormat

For each test case, print the result (the number of ways) on a new line to the standard output (stdout).

## sample
4
15
10
1
9
4

2 1 3

</p>