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:
- Triplets
- Ways to Sum
- Consecutive Sum
- Disk Space Analysis
- Do They Belong?
- Global Maximum
- Initial Public Offering
- Inversions
- Portfolio Balances
- Prime Factor Visitation
- Profit Targets
- Sprint Training
- Throttling Gateway
- Birthday Card Collection
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