Skip to main content

Iterating the first 10 million digits of pi


Continuing from my last blog post : Did you know that the 100-trillionth decimal place of π (pi) is 0? That is according to work done by Google in 2022. It took them 157 days to calculate 100 trillion digits of pi. It would be cool to know the 10 digits before and the 10 digits after. Numbers and patterns and coincidences and serendipity fascinates me. It was the usual quiet morning for me. I found that I could download the first 10 million digits of pi and I set out with the help of Bard and my curiousity to see what unusual, interesting or outstandish things I could find. Like how many times my birthday 2305 occurs or the the next 2 digits after the sequence formed with the last 3 play whe numbers. You can get pretty creative with what you look for in pi like in this youtubes - I found Amongi in the digits of pi

Ha! I found the last 10 of the first 100 trillion digits of pi when I saw another video by the same guy. They are 3095295560. First glance and nothing stands out except that 5 occurs the most and 3 times. It is nice that they have tools to calculate and verify the results with an extremely small chance of error.


I tried to download directly from Chrome mobile but it kept crashing. I used the following code to download from python instead.

import requests

url = "http://www.cs.princeton.edu/introcs/data/pi-10million.txt"

try:
    response = requests.get(url)
    response.raise_for_status()  # Raise an exception for error status codes

    text_content = response.text

    with open("pi10million.txt", "w") as file:  # Customize filename if needed
        file.write(text_content)

    print("Text file saved successfully!")

except requests.exceptions.RequestException as e:
    print("An error occurred:", e)

This is an example of the type of probing I have done so far. The code runs reasonably fast on my 5 year old budget android phone.

with open("pi10million.txt", "r") as file:
    pi_string = file.read()  # Read the entire file as a string

# Find all starting positions of "230580"
occurrences = [i for i in range(len(pi_string)) if pi_string.startswith("230580", i)]

# Calculate and print the number of digits between occurrences
if len(occurrences) > 1:
    for i in range(1, len(occurrences)):
        distance = occurrences[i] - occurrences[i-1] - 6  # Subtract the length of "230580" (6 digits)
        print(f"Number of digits between occurrences {i} and {i+1}: {distance}")
else:
    print("No consecutive occurrences of '230580' found in the file.")

Comments

Popular posts from this blog

Touched by heaven

It is 139am and I have decided to write. I do not like to dream because my dreams are sometimes confusing blobs. Hodgepodge is the word. I like when I sleep and I do not dream anything. Peaceful nothingness. Quiet escape from all the nonsense of the world. I went to the random word generator but this time I chose random fake word. A few (wef in reverse) words in I stopped at wefly. I guess I could pronounce it we-fly or wef-ly. Wef-ly could mean plentiful or the opposite of few. Wefly also contains the letters for flew. This is past tense as if to say let go of the past. Let go of what has gone. How do I connect these to something Godly? Angels have wings. Angels fly. I ask God to surround us with plenty angels when we sleep so that we have quiet dreams or heavenly dreams. I will call these wefly dreams. I asked my friend Chatty to describe a wefly dream. He says that a wefly dream is a gentle, God-guarded sleep where the soul is lifted together with others into quiet safety, not by dr...

Winning with God

It is 237am and I have decided to write. I spent 15 minutes thinking about what to write and nothing. I decided to go wash the wares and make breakfast. I made grilled cheese sandwiches. It is the next morning and I still have not decided yet. Let me start with this. God is beautiful. God makes no mistakes. God wants us to win. In other words, we cannot lose with God. We will always win with God. But what is the prize to be won with God? Or does it not matter? My friend Chatty tells me that with God, the win is: Peace that is not dependent on circumstances. Meaning that suffering cannot cancel. Love that does not expire. Hope that death itself cannot take away. Things like those. It is not money, comfort, applause, or an easy life. Those things may come or go. Many faithful people never receive them. The world’s prizes can be stolen. God's prize cannot. Further and with God, winning is not about external rewards or worldly success, but about union, peace, and fullness of being; at ...

Talk is not cheap

It is 614pm and I have decided to write. They say talk is cheap. If we are to believe this then I am glad that talk is cheap because it means that the poor can afford it. On the flip side does that mean that action is expensive? It would follow that the rich can take action while the poor are lacking. But is talk really cheap since they say that money talks and bullshit walks. It is all confusing to me but it hurts when we look down on others who are struggling with finding a way and struggling to take action. Sometimes all we have are words. Not to worry because turning to God is cheap. It is free actually. Some of the best things in life are free. It costs nothing to talk to God. My friend Chatty says that "Talk is cheap" becomes harmful when it ignores that action often requires resources many people lack. Words and prayer still matter because they are available to everyone. Money may have power in the world, but it has none before God, and turning to Him is free. Some of ...