Skip to content
Generates Pi from random numbers and co-primes
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This program generates random numbers, and calculates Pi based off the odds that those two numbers are co-prime. This was mostly just an excuse for me to learn concurrency in Rust, which I was fairly successful with. Change the num_runs variable to increase or decrease the number of trials.

This was inspired by this video by Matt Parker.

If you like this, you might also be interested in my pi-generator-from-blocks repository, where I calculate Pi using elastic collisions.

You can’t perform that action at this time.