Skip to content

Instantly share code, notes, and snippets.

@LuxXx
Created February 20, 2018 12:57
Show Gist options
  • Save LuxXx/b6ddc7d122e19b0795294398a46cda4c to your computer and use it in GitHub Desktop.
Save LuxXx/b6ddc7d122e19b0795294398a46cda4c to your computer and use it in GitHub Desktop.
weirdest euler approximation based on https://twitter.com/AnalysisFact/status/961338838084878337
public class WeirdEuler {
public static int N = 1000000;
public static double ak(int k) {
if (k == 0) return 2;
double product = 1;
for (int i = k; i < 2*k; i+=2) {
product *= ((double) (i+2)) / (i+1);
}
return Math.pow(product, 1.0 / k);
}
public static void main(String[] args) {
double e = ak(0);
for (int i = 2; i < N; i*=2) {
e *= ak(i);
}
System.out.println(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment