import java.util.*;
public class Ch2Q39
{
public static void main(String[] args)
{int n;
double x, sum = 0, term = 1;
Scanner kbd = new Scanner(System.in);
System.out.print("Enter x: ");
x = kbd.nextDouble();
System.out.print("Enter no of terms: ");
n = kbd.nextInt();
for(int i = 1; i <= n; i++)
{sum += term;
term *= x/i;
}
System.out.println("Sum = "+ sum);
}
}
No comments:
Post a Comment