Given a number n, return the sum of the first n numbers.
Return false for invalid inputs (non-number, negative numbers, or non-integer values).
Examples
Input: n = 5
Output: 15
Input: n = 0
Output: 0
Input: n = 1
Output: 1
Constraints
- Input must be a non-negative integer.
- Return false for invalid inputs.
Function Signature
function sumN(n) {
// Your code here
}
Test Cases
- Base cases: 0, 1
- Small numbers: 2, 3, 5
- Larger numbers: 10, 100
- Invalid inputs: -1, 2.5, "5", null, undefined, [], {}