Python Practice › Loop Programs › Program 51

Sum of odd numbers 1 to 100

EasyLoop Programs · 51 of 90

Write a Python program to calculate the sum of all odd numbers from 1 to 100.

Advertisement
Output
2500

Approach

  1. Loop over odd numbers and add them.

Solution

Python
total = 0for n in range(1, 101, 2):    total += nprint(total)
Output
2500

Learn the concept

New to this topic? Read the lesson, then come back.

More loop programs

← All 90 Loop Programs

Leave a Comment