Skip to content
Onsite

Sum of Odd Numbers up to N

EasyP3Coding

Return the sum of all odd numbers from 1 to n inclusive.

Example 1

Input
n = 10
Output
25

Example 2

Input
n = 1
Output
1

Example 3

Input
n = 2
Output
1

Constraints

  • 1 <= n <= 10^6

Hints

Run checks the 3 visible tests, Submit all 8.