f | import math | f | import math |
| from decimal import * | | from decimal import * |
| | | |
| | | |
| def PiGen(): | | def PiGen(): |
| getcontext().prec = 9999 | | getcontext().prec = 9999 |
n | sum = Decimal('0') | n | ans = Decimal('0') |
| q = 0 | | k = 0 |
| fst_num = 426880*Decimal.sqrt(Decimal('10005')) | | chislo1 = 426880*Decimal.sqrt(Decimal('10005')) |
| while True: | | while True: |
t | scd_num = math.factorial(6*q) * (13591409 + 545140134 * q) | t | chisl = math.factorial(6*k) * (13591409 + 545140134 * k) |
| scd_den = math.factorial( | | znam = math.factorial(3*k) * (math.factorial(k) ** 3) * \ |
| 3*q) * (math.factorial(q) ** 3) * (Decimal('-262537412640768000') ** q) | | (Decimal('-262537412640768000') ** k) |
| sum += scd_num/scd_den | | ans += chisl/znam |
| q += 1 | | k += 1 |
| res = fst_num/sum | | res = chislo1/ans |
| yield res | | yield res |
| | | |