A Python program that streams the digits of π (pi) indefinitely, calculated digit-by-digit using Jeremy Gibbons' infinite spigot algorithm.
- Real-time digit-by-digit computation of π.
- Minimal memory usage (no precomputed values stored).
- Clean, generator-based implementation for seamless integration into other projects.
- Python 3.x
- Clone the repository:
git clone https://github.com/TianmuTNT/PiDigits.git cd PiDigits
- Run the script:
python3 pi_digits.py
- The program will print
3.
followed by the decimal digits of π, one by one. - Press
Ctrl+C
to stop execution.
This implementation uses the infinite spigot algorithm by Jeremy Gibbons. Unlike finite spigot methods, it avoids preallocating memory for all digits and generates them on-the-fly.
This project is licensed under the MIT License. See LICENSE for details.
For Educational Purposes Only
This code is intended to demonstrate algorithmic concepts and is not optimized for high-performance π computation.
Feel free to open issues or submit pull requests for improvements.