s = (1/0!)+(x/1!)+((x^2)/2!)+((x^3)/3!)+((x^4)/4!)+.....+((x^n)/n!)
*/
import java.util.Scanner;
public class algoritmo_5_suma_serie {
public static void main(String[] args) {
Scanner leer=new Scanner(System.in);
int n,x,factorial=1;
double sumaTotal=0;
System.out.print("Ingrese N :");
n=leer.nextInt();
System.out.print("Ingrese X :");
x=leer.nextInt();
//la serie inicia en 0
for (int i = 0; i <= n; i++) {
if(i>=1){
factorial=1;
//calculando el factorial
for (int j = 1; j <= i; j++) {
factorial=factorial*j;
}
}
sumaTotal=sumaTotal+(Math.pow(x, i))/factorial;
}
System.out.println("Suma Total de La Serie es: "+sumaTotal);
}
}
0 comments:
Publicar un comentario