Skip to content

Instantly share code, notes, and snippets.

@oriapp
Created August 1, 2022 17:37
Show Gist options
  • Save oriapp/67028539cf046da23fe9cd913a838dd2 to your computer and use it in GitHub Desktop.
Save oriapp/67028539cf046da23fe9cd913a838dd2 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main() {
double long k = 1,
s = 0;
for (size_t i = 0; i < 1000000; i++)
{
if (i % 2 == 0)
s += 4/k;
else
s -= 4/k;
k += 2;
}
printf("[PI] %Lf\n", s);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment