···11from math import factorial
22from decimal import Decimal, getcontext
33+import time
44+import threading
55+36print("Pistributed, an app to calculate Pi with distributed power.")
47print("Do not run on systems owned by another entity, entities, person, or people, without explicit permission from them.")
58print("""This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
···811912You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.""")
1013print("By continuing, you agree to these terms, disclaimers, and acknowledge that there is NO WARRANTY.")
1111-input("I agree, and would like to continue. (to continue, press enter)")
1414+input("I agree, and would like to continue. (to continue, press enter) ")
1215print("Thanks for confirming! I just need one more thing.")
1316server = input("What is the server URL that you'd like to connect to? (ex: example.com) ")
1417print("Alright! Thanks. Let the calculating begin :D (to exit, run ctrl+c or close terminal)")
1518print("-------------------")
1616-getcontext().prec=100
1717-def calc(n):
1818- t= Decimal(0)
1919+2020+def calc(n, prec):
2121+ getcontext().prec = prec
2222+ t = Decimal(0)
1923 pi = Decimal(0)
2020- deno= Decimal(0)
2121- k = 0
2424+ deno = Decimal(0)
2225 for k in range(n):
2323- t = ((-1)**k)*(factorial(6*k))*(13591409+545140134*k)
2424- deno = factorial(3*k)*(factorial(k)**3)*(640320**(3*k))
2525- pi += Decimal(t)/Decimal(deno)
2626- pi = pi * Decimal(12)/Decimal(640320**Decimal(1.5))
2626+ t = ((-1)**k) * (factorial(6*k)) * (13591409 + 545140134*k)
2727+ deno = factorial(3*k) * (factorial(k)**3) * (640320**(3*k))
2828+ pi += Decimal(t) / Decimal(deno)
2929+ pi = pi * Decimal(12) / Decimal(640320**Decimal(1.5))
2730 pi = 1/pi
2831 return pi
2929-print(calc(100))3232+3333+def upload():
3434+ while True:
3535+ print(">> uploading latest calculation")
3636+ time.sleep(60)
3737+3838+threading.Thread(target=upload, daemon=True).start()
3939+4040+calculation = 1
4141+precision = 10
4242+4343+while True:
4444+ pi_val = calc(calculation, precision)
4545+ print(pi_val)
4646+ calculation += 1
4747+ precision += 5