#C8715. Consecutive Numbers Sum

    ID: 52728 Type: Default 1000ms 256MiB

Consecutive Numbers Sum

Consecutive Numbers Sum

Given a positive integer N, determine the number of ways to express N as a sum of consecutive positive integers. In mathematical terms, for a sequence starting from a with k consecutive numbers, we have:

\( N = k \times a + \frac{k(k-1)}{2} \)

A valid representation exists if a is a positive integer. For example, when N is 15, the valid sequences include:

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

inputFormat

The input is a single integer N (1 ≤ N ≤ 109) provided via standard input.

outputFormat

Output a single integer representing the number of ways N can be expressed as a sum of consecutive positive integers.

## sample
5
2

</p>