Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Using a simple formula derived from Hurwitz zeta function,
|
||||
* as described on https://en.wikipedia.org/wiki/Euler%27s_constant,
|
||||
* gives a result accurate to 12 decimal places.
|
||||
*/
|
||||
public class EulerConstant {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(gamma(1_000_000));
|
||||
}
|
||||
|
||||
private static double gamma(int N) {
|
||||
double gamma = 0.0;
|
||||
|
||||
for ( int n = 1; n <= N; n++ ) {
|
||||
gamma += 1.0 / n;
|
||||
}
|
||||
|
||||
gamma -= Math.log(N) + 1.0 / ( 2 * N );
|
||||
|
||||
return gamma;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue