Computer Science, asked by Hemangi3060, 6 months ago

Write a program to find the sum of series 4+9+14+..........+74

Answers

Answered by Equestriadash
12

The following codes are written in Python.

s = 0

for i in range(4, 75, 5):

   s = s + i

print(s, "is the sum of the numbers in the series 4, 9, 14, ... 74.")

I've used a for loop for this.

for loop is an iteration statement used for repeatedly checking over a given sequence/condition.

In the above coding, the variable i, takes all the values in the sequence 4, 9, 14, ... 74 and adds them up.

The syntax of range() is as follows:

range(start, stop, step)

  • start - indicated the starting value
  • stop - indicates the stopping value
  • step - indicates by how much the sequence must skip

An important note to keep in mind is that the stop value is never displayed when the program is made to run.

For instance, if you give the stop value as 5, when the program runs, it will stop at 4.

Hence, accordingly, you must give your values.

Similar questions