Sum of First N Odd Integers
Given an integer n
, return the sum of the first n
positive odd integers.
Constraints
n ≤ 1,000
https://binarysearch.com/problems/Sum-of-First-N-Odd-Integers
Examples
Example 1
Input
- n =
5
Output
- answer =
25
Explanation
The first 5
odd integers are [1, 3, 5, 7, 9]
and its sum is 25
.
Leave a comment