Skip to content

Instantly share code, notes, and snippets.

@Basicprogrammer10
Last active November 7, 2021 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Basicprogrammer10/c97d866b7178a97baca73ed52e54a68d to your computer and use it in GitHub Desktop.
Save Basicprogrammer10/c97d866b7178a97baca73ed52e54a68d to your computer and use it in GitHub Desktop.
from datetime import datetime
import decimal
file = open('Pi.txt', 'w')
file.write("Pi Finder V2\n")
file.write("Made By Connor Slade\n")
def pi():
decimal.getcontext().prec += 2
three = decimal.Decimal(3)
lasts, t, s, n, na, d, da = 0, three, 3, 1, 0, 0, 24
while s != lasts:
lasts = s
n, na = n + na, na + 8
d, da = d + da, da + 32
t = (t * n) / d
s += t
decimal.getcontext().prec -= 2
return +s
x = int(input("precision: "))
file.write("Precision: " + str(x) + "\n")
file.write("-------------------------\n")
decimal.getcontext().prec = x
pi = pi()
file.write(str(pi) + "\n")
file.write("-------------------------\n")
file.write("Finished at " + str(datetime.now()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment