A fast pi calculator using the Chudnovsky algorithm. Written in Rust.
Computes pi to arbitrary precision with an explicit upper bound of 100,000,000 decimal digits.
pi-calc [FLAGS] [DIGITS]
DIGITS-- number of decimal digits (default: 1000, max: 100,000,000)-q, --quiet-- suppress timing info, output only the digits-h, --help-- print help
pi-calc # 1000 digits
pi-calc 100 # 100 digits
pi-calc -q 10000 # 10000 digits, quiet mode
Uses the Chudnovsky algorithm, the same method used for world-record pi computations. Each iteration yields ~14.18 digits.
The implementation uses GMP (via the rug crate) for arbitrary-precision integer and floating-point arithmetic.
Runtime depends on the requested precision, CPU, Rust toolchain, and GMP/MPFR build. An illustrative single warm run on an Apple M4 Max with Rust 1.96.1 took about 0.04 seconds for 10,000 digits and 10.5 seconds for 100,000 digits. These are observations, not cross-machine guarantees.
To measure the release build on your machine without including terminal output time:
cargo build --release
/usr/bin/time -p target/release/pi-calc --quiet 100000 > /dev/nullRequires Rust 1.75+ and GMP/MPFR dev libraries.
# Debian/Ubuntu
sudo apt install libgmp-dev libmpfr-dev libmpc-dev
cargo build --releaseThe integration suite verifies output digits and CLI error handling:
cargo test
cargo clippy --all-targets --all-features -- -D warningsMIT