Find where in the digits of Pi the digits of your birthday occur.
Run the code to get the first 1,000 digits of Pi. Try more digits:
Get a list of the first 20 digits of Pi in base 10, plus the number of digits to the left of the decimal point:
Get just the list of digits:
Find where your birthday occurs in the digits of Pi. Try other sequences of digits:
Note: increase the number of digits of Pi until you find your sequence; e.g. try 10 times more digits each time.
Note: sequences of digits longer than 6 may require a very long time to compute.
Make a list of the digits of your birthday—for example, for November 17, 1999:
Find the position of that sequence in the digits of Pi:
The pairs of numbers are the positions in the digits of Pi of the first and last digits of the sequence. If the sequence occurs more than once, you’ll get more than one pair. If the sequence doesn’t occur at all, you’ll get the empty list {}.
Increase the number of digits of Pi if your sequence is not found. For example, try 10 times more digits.
Print the digits of Pi, ending at the first occurrence of your birthday:
Find the position of your birthday in the digits of Pi. Increase the number of digits, if necessary, to find the sequence:
The end of the first occurrence of the sequence is 49,707. Get the first 49,707 digits of Pi and give it the name digits:
49,707 digits are way too many to print, so instead make an abbreviated form.
This gives the first 100 digits:
This gives the last 100 digits (-1 means the last digit, -100 means the 100th-from-last digit):
Row formats a list of objects without the braces, commas, and quotation marks—for example:
Use Row to show the first 100 digits, an ellipsis (...), and the last 100 digits. Flatten flattens out the sublists of digits:
Restore the decimal point by omitting the first digit and supplying the missing 3 and decimal point explicitly:
This code is essentially what was implemented to make the Wolfram My Pi Day site.