Антон Щербаков, 523 IterPi 9054 | Кузнецов Егор Дмитриевич, ФКИ, 6-ой курс IterPi 10215 | ||||
---|---|---|---|---|---|
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) | ||
3 | counter = 0 | 3 | counter = 0 | ||
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) | ||
7 | if counter == 0: | 7 | if counter == 0: | ||
8 | yield '.' | 8 | yield '.' | ||
n | 9 | counter += 1 | n | 9 | counter += 1 |
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 | ||
t | 16 | nn = (q * (7 * k) + 2 + r * l) // (t * l) | t | 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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|