354,476 views
33 votes
33 votes
Write code using the range function to add up the series 3, 6, 9, 12, 15, ..... 66 and print the resulting sum. Expected Output 759

User Neilakapete
by
2.9k points

1 Answer

23 votes
23 votes

Answer:

The program is as follows:

total = 0

for i in range(3,67,3):

total += i

print(total)

Step-by-step explanation:

This initializes the sum of the series to 0

total = 0

This iterates through the series with an increment of 3

for i in range(3,67,3):

Add up all elements of the series

total += i

Print the calculated sum

print(total)

User Nasima
by
3.0k points