Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
java: Calcula el numero euler basado en el factorial
public class Euler {
public static long fact(int x) {
long prod = 1;
for (int i = 1; i < x; i++) {
prod = prod * i;
return prod;
public static double euler(){
double e = 0;
for (int i = 1; i < 50; i++) {
e = e+1 / (double) (fact(i));
return e;
public static void main(String[] args) {
System.out.println("e = "+euler());

This comment has been minimized.

Copy link

@jonerruiz jonerruiz commented May 14, 2018

Creo que el método para calcular el factorial (fact), presenta un error en el número de iteraciones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment