https://github.com/tianmutnt/pidigits
A Python implementation of an infinite spigot algorithm to compute and stream the digits of π (pi) in real-time. This project is designed for educational purposes to demonstrate how π can be calculated and output digit-by-digit using an efficient iterative approach.
https://github.com/tianmutnt/pidigits
infinite pi pidigits python
Last synced: 4 months ago
JSON representation
A Python implementation of an infinite spigot algorithm to compute and stream the digits of π (pi) in real-time. This project is designed for educational purposes to demonstrate how π can be calculated and output digit-by-digit using an efficient iterative approach.
- Host: GitHub
- URL: https://github.com/tianmutnt/pidigits
- Owner: TianmuTNT
- License: mit
- Created: 2025-02-25T01:52:21.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-02-27T12:54:08.000Z (8 months ago)
- Last Synced: 2025-05-31T19:48:54.482Z (5 months ago)
- Topics: infinite, pi, pidigits, python
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PiDigits
[](https://opensource.org/licenses/MIT)
A Python program that streams the digits of π (pi) indefinitely, calculated digit-by-digit using Jeremy Gibbons' infinite spigot algorithm.
## Features
- Real-time digit-by-digit computation of π.
- Minimal memory usage (no precomputed values stored).
- Clean, generator-based implementation for seamless integration into other projects.## Usage
### Prerequisites
- Python 3.x### Running the Program
1. Clone the repository:
```bash
git clone https://github.com/TianmuTNT/PiDigits.git
cd PiDigits
```
2. Run the script:
```bash
python3 pi_digits.py
```
3. The program will print `3.` followed by the decimal digits of π, one by one.
4. Press `Ctrl+C` to stop execution.## Algorithm Details
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.## License
This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.## Disclaimer
**For Educational Purposes Only**
This code is intended to demonstrate algorithmic concepts and is not optimized for high-performance π computation.## Contributing
Feel free to open issues or submit pull requests for improvements.