24 lines
553 B
Python
24 lines
553 B
Python
from binseq import REAL
|
||
from math import isqrt # integer sqrt
|
||
|
||
# Theorem 3.1 (2)
|
||
# Es gibt eine berechenbare Folge (qn)n∈N rationaler Zahlen, die schnell gegen x konvergiert.
|
||
# d.h. |x − qi| < 2^(−i) für alle i ∈ N.
|
||
|
||
# bin_seq(1/3) = 0.010101...
|
||
def one_third(n):
|
||
if n == 1: return "."
|
||
if n % 2 == 0: return "0"
|
||
return "1"
|
||
|
||
|
||
def irrational(n):
|
||
if n == 1: return "."
|
||
if n != isqrt(n) * isqrt(n): return "1"
|
||
return "0"
|
||
|
||
|
||
x = REAL(one_third)
|
||
y = REAL(irrational)
|
||
|
||
print("x: " + x.as_string(50) + "\ny: " + y.as_string(50)) |