Computer Science, asked by DEEPTANSHA7647, 10 months ago

Python program for find the 15th term of the following series 0,0,7,6,14,12,21,18,28,........

Answers

Answered by fiercespartan
8

We will first put in our starter code which is 0,0,7,6 and then what we need to do is add two numbers to the series.

(1) The first number would be the multiple of 7 starting from 2

(2) The second number would be the multiple of 6 starting from 2

First off, lets have a list named series and put in out starter code.

series = [0,0,7,6]

Now we need the the 15th term, so we will use a while loop to do a function until the length of the list is 15.

The basic idea of the function is. We will first have to append the multiple of 7, then the multiple of 6, then the multiple of 7 and it continues.

So, lets take a 'n' as 2 as out multiples start from 2.

And then, after we append the multiples of 7 and 6 with 2, we add 1 to the value of n and then it would become 3 and then we append the multiples of 7 and 6 with 3.

CODE:

series = [0,0,7,6]

n = 2

while len(series) < 15:

  series.append(7*n)

  series.append(6*n)

print('The 15th term is:',series[-1])

This is if the 15 th term is counted from 0. If it is counted from 1, then we use series[-2]

Similar questions