Computer Science, asked by aditisingh12468, 5 months ago

WAP to print the sum of the following series S=x^2-x^4+x^6-x^8 up to n terms​

Answers

Answered by mishraabhi8924
0

Explanation:

python language :

a=int(input("enter the number")) # value of x

b=int(input("enter the number of term"))

#value of n

sum=0

for I in range(1,b):

if (i%2==0):

sum=sum-pow(a,2*i)

else:

sum=sum+pow(a,2*i)

print(sum)

if you want the answer with different programming language then DM me

Answered by anindyaadhikari13
1

Question:-

Write a program to print the sum of the series.

S=x^2 - x^4 + x^6 - x^8...N terms.

Program:-

class Program

{

public static void main(String args[])

{

int n=10, x=5, a=2;

double s=0.0;

for(int i=1;i<=n;i++)

{

if(i%2==1)

s+=Math.pow(x, a);

else

s-=Math.pow(x, a);

a=a+2;

}

System.out.println("Sum of the series: "+s);

}

}

Similar questions