Sum of the odd numbers



Problem to sum the odd numbers until the given number N.



Example-1:


Input    : n = 5
Output   : 9
Explain  : 1+3+5 = 9.  


Example-2:


Input    : n = 10
Output   : 25
Explain  : 1+3+5+7+9 = 25.  







Solution




n = 5

k = 0

for i in range(1,n+1):

    if(i % 2 == 1):

        k += i

print(k)



Output



9