t | import math | t | import math |
| from decimal import * | | from decimal import * |
| getcontext().prec = 1010 | | getcontext().prec = 1010 |
| | | |
| def PiGen(): | | def PiGen(): |
| pi = Decimal(13591409) | | pi = Decimal(13591409) |
| ak = Decimal(1) | | ak = Decimal(1) |
| k = 1 | | k = 1 |
| while k < 1010: | | while k < 1010: |
| ak *= -Decimal((6 * k - 5) * (2 * k - 1) * (6 * k - 1)) / Decimal(k * k * k * 26680 * 640320 * 640320) | | ak *= -Decimal((6 * k - 5) * (2 * k - 1) * (6 * k - 1)) / Decimal(k * k * k * 26680 * 640320 * 640320) |
| val = ak * (13591409 + 545140134 * k) | | val = ak * (13591409 + 545140134 * k) |
| d = Decimal((6 * k - 5) * (2 * k - 1) * (6 * k - 1)) / Decimal(k * k * k * 26680 * 640320 * 640320) | | d = Decimal((6 * k - 5) * (2 * k - 1) * (6 * k - 1)) / Decimal(k * k * k * 26680 * 640320 * 640320) |
| pi += val | | pi += val |
| k += 1 | | k += 1 |
| pi = pi * Decimal(10005).sqrt() / 4270934400 | | pi = pi * Decimal(10005).sqrt() / 4270934400 |
| pi = pi ** (-1) | | pi = pi ** (-1) |
| pi = str(pi) | | pi = str(pi) |
| for i in range(len(pi)): | | for i in range(len(pi)): |
| yield pi[i] | | yield pi[i] |