@sek/# 314-Digits

Files

- main.py

main.py

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

```
def pi():
r = 4*(4*arccot(5) - arccot(239))
return str(r)[0]+'.'+str(r)[1:-5]
def arccot(x):
total = power = 10**319 // x
divisor = 1
while abs(power) >= divisor:
power = -power // x**2
divisor += 2
total += power // divisor
return total
print("314 digits of Pi " + pi())
"""
Shirt: $19.99: https://www.amazon.com/dp/B07BBGG9B5
Free shipping for Prime members =)
-----
This python code was crafted to be short enough to fit on a t-shirt, but still readable.
Running the code on the front of the shirt produces the output on the back.
Press the play button above to generate this output.
This algorithm was developed in 1706! For more info, see: https://en.wikipedia.org/wiki/John_Machin
and: https://www.craig-wood.com/nick/articles/pi-machin/
The arccot method uses integer math to calculate an arc cotangent. See here for info on what an ArcCot is: http://reference.wolfram.com/language/ref/ArcCot.html
The 319 on line 6 is the length of the integer to start with (1 followed by 319 zeros) and therefore sets the precision of the end result.
The algorithm ends up with a few incorrect digits at the end of the result - This is why 319 is used instead of 314, and also explains the -5 on line 3 which drops the erroneous digits.
Some sites that can verify the output:
- http://3.141592653.com/
- http://www-groups.dcs.st-and.ac.uk/history/HistTopics/1000_places.html
"""
```