# Python: Sum integers from 1 to N the easiest way

( 26 Articles)

This’s a short and straight to the point guide to calculating the sum of integers from 1 to n in Python.

**The code: **

```
def sum(n):
result = 0
for i in range(n):
result += i
print(str(result))
# n = 100
sum(100)
# n = 1000
sum(1000)
```

**Output:**

```
4950
499500
```

#### Related Articles

Subscribe

0 Comments