Given a number n, determine whether it can be expressed as the sum of two or more consecutive positive integers. Return true or false.
Examples
Input: n = 9
Output: true
Explanation: 9 = 2 + 3 + 4
Input: n = 15
Output: true
Explanation: 15 = 4 + 5 + 6 or 1 + 2 + 3 + 4 + 5
Input: n = 10
Output: true
Explanation: 10 = 1 + 2 + 3 + 4
Input: n = 8
Output: false
Explanation: 8 cannot be expressed as sum of consecutive integers
Input: n = 1
Output: false
Explanation: 1 cannot be expressed as sum of two or more consecutive integers
Constraints
1 ≤ n ≤ 10^9
Return false for:
- n = 1 (requires at least 2 consecutive integers)
- n < 1
Test Cases
Base Cases
Valid Sums
n = 9
n = 15
n = 10
n = 21
Invalid Sums
Edge Cases
Large Numbers