Given a long integer, num
, find the number of ways to represent it as a sum of two or more consecutive positive integers. For example:
num = 15
, then there are three such ways: (1 + 2 + 3 + 4 + 5) = (4 + 5 + 6) = (7 + 8) = 15
.num = 2
, then there are zero such ways.
Complete the consecutive
function in the editor below. It has one parameter: a long integer named num
. The function must return an integer denoting the number of ways to represent num
as a sum of two or more consecutive positive integers.
Input Format
Locked stub code in the editor reads a long integer denoting num
from stdin and passes it to the function.
Constraints
1 ≤ num ≤ 10^12
Output Format
Return an integer denoting the number of ways to represent num
as a sum of two or more consecutive positive integers.
Example 1:
Input: num = 15
Output: 3
Explanation:Might or might not be an accurate explanation :)There are three ways to represent
num = 15
as a sum of two or more consecutive positive integers:
(1 + 2 + 3 + 4 + 5)
(4 + 5 + 6)
(7 + 8)
Therefore, the function returns
3
.
1 ≤ num ≤ 10^12

input:
output: