Created
September 2, 2011 05:23
-
-
Save onlyangel/1187973 to your computer and use it in GitHub Desktop.
sum n!/n^n, n=1 to infinity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class T2 { | |
public static void main(String arg[]){ | |
double acum = 0; | |
for (int n = 1;n<=10;n++){ | |
acum+=factorial(n)/nALaN(n,n); | |
} | |
System.out.print(acum); | |
} | |
public static Long factorial(int i){ | |
if (i==1){ | |
return new Long(1); | |
}else{ | |
return i*factorial(i-1); | |
} | |
} | |
public static double nALaN(int i, int n){ | |
if (i==1){ | |
return n; | |
}else{ | |
return n*nALaN(i-1,n); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment