Skip to content

Instantly share code, notes, and snippets.

@kylelk
Created October 19, 2013 20:20
Show Gist options
  • Save kylelk/7061024 to your computer and use it in GitHub Desktop.
Save kylelk/7061024 to your computer and use it in GitHub Desktop.
computes euler's constant to 32 places 2.71828182845904553488480814849027
#include <stdio.h>
long factorial(int n) {
long result = 1;
for (int i = 1; i <= n; ++i)
result *= i;
return result;
}
int main ()
{
double n=0;
int i;
for (i=0; i<=32; i++) {
n=(1.0/factorial(i))+n;
}
printf("%.32f\n", n);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment