Write a program that generate a series using a function which take first and last values of series and then generates 4 terms that are equidistant

 




Write a program that generate a series using a function which take first and last values of series and then generates 4 terms that are equidistant

Steps to follow:


#1here we have to find series so first we must have to common difference between every number


#2 Now we will use formula i.e S=n/2*(2a+l)  ,ais first term and l is last term ,nis number of terms that we know.


#3Using this formula we find the of S and then we will find value of common difference similar formula i.eS=n/2*(2a+n-1)d)


#4 Then we get the value of  d=(S-4*a)/6

#because we know value n=4 


#5 Now we can find any term of series of the four terms



def sn(a,l):

S=2*(a+l)

d=(S-4*a)/6

series= a,"+",a+d,"+",a+2*d,"+",a+3*d

print(series)

a=int(1)

l=int(100)

sn(a,l)


No comments:

Powered by Blogger.