Computer Science, asked by biswadeepsaha67, 1 year ago

write a program in Java to find the sum of the following series:
(i)2-4+6-8+............20
(ii) 1+(1+2)+(1+2+3)+.......(1+2+3+.......+n)
(iii) 1+x^2/2+x^4/4+x^6/6+-------+x^18/18.

Answers

Answered by Punya2138
1

import java.io.*;

class Sum

{BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int n,x;

public void accept()throws IOException

{ System.out.println(" enter a no.");

n=Integer.parseInt(br.readLine());

System.out.println(" enter another no.");

x=Integer.parseInt(br.readLine());

}

public void calc()

{ int sum=0;

for(int x=2,y=4;y<=20;x+=4,y+=4)

{ sum=sum+x-y;

}

System.out.println(sum);

}

public void calculate()

{ int s=0;

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

{ for(int d=1;d<=j;d++)

s=s+d;

}

System.out.println(s);

}

public void chk()

{ int sums=1;

for(int g=1;g<=18;g++)

{ sums=sums+Math.pow(x,g)/g;

}

System.out.println(sums);

}

}

Similar questions