Last active
March 12, 2021 11:33
-
-
Save nmmmnu/fde1f0b7406372a3adbec9a72a3c61e6 to your computer and use it in GitHub Desktop.
pi.2021.cc
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
#include <cstdio> | |
using myfloat = double; | |
constexpr size_t MAX = 2'500'000'000; | |
int main(){ | |
myfloat sum = 0; | |
myfloat const four = 4; | |
for(size_t i = 0; i < MAX; ++i) | |
sum += 1 / (four * i + 1) - 1 / (four * i + 3); | |
myfloat const pi = sum * four; | |
printf("%f\n", pi); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment