-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path751.py
36 lines (31 loc) · 767 Bytes
/
751.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from decimal import Decimal
from math import floor
def b(theta, n):
if n < 1:
raise ValueError('b_n, n >= 1')
elif n == 1:
return theta
else:
bn1 = b(theta, n - 1)
fbn1 = floor(bn1)
return fbn1 * (bn1 - fbn1 + 1)
def a(theta, n):
return floor(b(theta, n))
def tau(theta, minlen=24):
digits = ''
n = 2
while len(digits) < minlen:
digits += str(a(theta, n))
n += 1
return Decimal('2.' + digits)
def fixedpoint(start=2):
current = Decimal(start)
while True:
yield current
t = tau(current)
if str(t) == str(current):
break
current = t
if __name__ == '__main__':
for i, t in enumerate(fixedpoint(), 1):
print(i, t)