alex_kole IterPi 9485 | Каретин Николай Ильич, 522 IterPi 9869 | ||||
---|---|---|---|---|---|
f | 1 | def PiGen(): | f | 1 | def PiGen(): |
2 | q, r, t, k, n, l = (1, 0, 1, 1, 3, 3) | 2 | q, r, t, k, n, l = (1, 0, 1, 1, 3, 3) | ||
n | 3 | decimal_point = False | n | 3 | dot = True |
4 | while True: | 4 | while True: | ||
5 | if 4 * q + r - t < n * t: | 5 | if 4 * q + r - t < n * t: | ||
6 | yield str(n) | 6 | yield str(n) | ||
n | 7 | if not decimal_point: | n | 7 | if dot: |
8 | yield '.' | 8 | yield '.' | ||
t | 9 | decimal_point = True | t | 9 | dot = False |
10 | nr = 10 * (r - n * t) | 10 | nr = 10 * (r - n * t) | ||
11 | n = 10 * (3 * q + r) // t - 10 * n | 11 | n = 10 * (3 * q + r) // t - 10 * n | ||
12 | q *= 10 | 12 | q *= 10 | ||
13 | r = nr | 13 | r = nr | ||
14 | else: | 14 | else: | ||
15 | nr = (2 * q + r) * l | 15 | nr = (2 * q + r) * l | ||
16 | nn = (q * (7 * k + 2) + r * l) // (t * l) | 16 | nn = (q * (7 * k + 2) + r * l) // (t * l) | ||
17 | q *= k | 17 | q *= k | ||
18 | t *= l | 18 | t *= l | ||
19 | l += 2 | 19 | l += 2 | ||
20 | k += 1 | 20 | k += 1 | ||
21 | n = nn | 21 | n = nn | ||
22 | r = nr | 22 | r = nr |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|