# Calculating and searching 500 billion digits of Pi

##### Greg Wilson

Director, Developer Advocacy

##### Ray Tsang

Developer Advocate

It's Pi day! Have you ever wondered whether you could take on the infinite irrationality of Pi and calculate its over one trillion digits? Well we wondered that exactly, and we found a way to calculate to 500 billion digits. Here's how:

Google Compute Engine supports up to eight 375GB Local SSDs per virtual machine instance! That gave us a total of 3TB of Local SSDs to use as swap space — exactly what we needed to calculate 500 billion digits, which is also exactly what we did.

Once the machine was setup, we were able to calculate 500 billion digits of Pi in about 44.9 hours. Assuming you already have a Google Cloud Platform account, and gcloud command line tool installed, here's how you can setup the instance:

- First, let’s set some variables to be used later. You’ll need to pick a zone to replace the ZONE variable.

- Next, create a large disk to hold the final output (500 billion digits will take up 500GB!)

- Then, create a Compute Engine instance with Local SSDs, the following command will attach 8 Local SSDs:

- Once the instance is started, you can SSH into it with:

- Once you're in the newly created instance, you'll need to first format and mount all of the Local SSDs and the large persistent disk:

- Finally, install the latest version of y-cruncher onto that instance. You may want to install screen or tmux as well.

To calculate digits of Pi, here is the command line I used to start y-cruncher on the virtual machine:

### Searching Pi Digits (Preview!)

y-cruncher certainly made it easy to calculate digits of Pi. For Pi Day 2016, Francesc Campoy, Jen Tong, Sara Robinson and I built a reverse lookup index in Google Cloud Bigtable, so that we can search a sequence of digits, such as your phone number and more! Here is a sneak preview of 2-million writes per second of Pi Digits into Cloud Bigtable:So that we can search a sequence of digits (up to 20 digits), and ask where in Pi does the first 9 digits of e appear? 6 occurrences! One in position 2,630,513,465!

Or, is there a sequence of nine 9’s “999999999”:

In position 4,329,769,635!

This was a big leap from last year, when we calculated 100 billion digits using y-cruncher running on last year's n1-highmem-32 of Compute Engine instance, which had 32-cores and 208GB of RAM and four Local SSDs.

Stayed tuned for more details on how we ingested billions of digits into Bigtable and how we built the Pi Search frontend.