from fractions import Fraction
from math import isqrt
def gen():
k = 1
while 1:
i = 1
while i <= k:
yield (i, k - i + 1)
i += 1
k += 1
g = gen()
seen = set()
n = 0
for _ in range(25):
a, b = next(g)
f = Fraction(a, b)
if not f in seen:
seen.add(f)
print(f"u{n} = {f}")
n += 1
else:
print("previously seen :", f"{a}/{b} = {f}")
To embed this program on your website, copy the following code and paste it into your website's HTML: