Skip to content

Instantly share code, notes, and snippets.

@z2s8
Last active August 29, 2015 14:07
Show Gist options
  • Save z2s8/749c017415e745b9aeb3 to your computer and use it in GitHub Desktop.
Save z2s8/749c017415e745b9aeb3 to your computer and use it in GitHub Desktop.
from timeit import timeit
from decimal import *
getcontext().prec = 200
print ("A PI értékének számítása folyamatban...")
def calc (prec = 100):
pi = Decimal(0)
for k in range (prec):
pi = pi + Decimal( (1/(16**k))*( (4/(8*k+1))-(2/(8*k+4))-(1/(8*k+5))-(1/(8*k+6)) ) )
print (pi)
print (timeit(calc, number = 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment