Solution :-
class p1{
void sumseries(int n,double x){
int i,a=1;
double s=0.0;
for(i=1;i<=n;i++){
s=s+x/a;
x=x*-1;
a++;
}
System.out.println(“Sum of series =”+s);
}
void sumseries(){
double s=0.0;
int i,f;
for(i=1;i<=20;i++){
f=1;
for(int j=1;j<=i;j++){
f=f*j;
}
s=s+f;
}
System.out.println(“Sum of series =”+s);
}
public static void main(){
p1 obj =new p1();
obj.sumseries(2,2);
obj.sumseries();
}
}