Back
Close

Odd Sum!

Statement

 Goal

Find the sum of the first N positive odd integers.

Example: If N=4, you should answer 16 because 1+3+5+7=16.
Input
A positive integer N.
Output
The sum of the first N positive odd integers.
Constraints
1 ≤ N ≤ 10^7
Example
Input
4
Output
16

Game modes
Fastest, Shortest

Test cases
Small Test
Input
4
Output
16

Validator 1 Validator
Input
5
Output
25

Medium Test
Input
18
Output
324

Validator 2 Validator
Input
19
Output
361

Large Test
Input
321
Output
103041

Validator 3 Validator
Input
123
Output
15129

Very Large Test
Input
9927813
Output
98561470962969

Validator 4 Validator
Input
9977511
Output
99550725755121

Solution language

Solution

Stub generator input