The Chudnovsky algorithm for calculating the digits of Pi.
Fun fact: it generated over 3 million digits in a little over 7 minutes on a regular, not very powerful machine.
cargo build --release
./target/release/chudnovsky 150 100
The output should look like this:
Approximation: 3.1415926535897932384626433832795028841971693980
Precision: 150
Iterations: 100
The number of iterations and the precision can both be modified via providing different arguments to the binary. The first and second arguments being the precision and the number of iterations respectively.
One could also directly change PRECISION
and ITERATIONS
constants in
src/main.rs
.
The bigger both variables, the more digits will be generated.
cargo test --release