Log in to add a comment

## Answers

{

public void main( int x,int n)

{

int sum = 1;

int sign = -1;

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

{

int num = (int)Math.pow(x,i);

int fact = 1;

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

{

fact = fact * j;

}

int term = num/fact;

sum = sum + (term * sign);

sign = sign * -1;

}

System.out.println( " the sum is :" + sum);

}

}