Citadel OA | Consecutive Sum | Citadel Online Assessment Question

Given a long integer, find the number of ways to represent it as a sum of two or more consecutive positive integers.

Relevant Citadel OA Problems:

Input

  • num: the target sum

Output

the number of ways to represent num as a sum of two or more consecutive positive integers

Examples

Example 1:

Input:

1num = 21

Output: 3

Explanation:

1+2+3+4+5+6 = 21 6+7+8 = 21 10+11 = 21

Constraints

  • 1<=num<=10^12

Try it yourself

Solution

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro